akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

class LCA:
    def __init__(self, edge, root):
        self.l = len(edge)
        self.stack = []
        self.stack.append((root, 0))
        self.vs = []
        self.depth = [0]*self.l
        self.firstVisited = [-1]*self.l
        while self.stack:
            v, d = self.stack[-1]
            if self.firstVisited[v] == -1:
                self.firstVisited[v] = len(self.vs)
            self.vs.append(v)
            self.depth[v] = d
            if edge[v]:
                self.stack.append((edge[v].pop(), d+1))
            else:
                self.stack.pop()
        
        self.n = len(self.vs)
        self.INF = (self.l, self.l)
        self.N0 = 1 << (self.n-1).bit_length()
        self.seg = [self.INF]*(self.N0 << 1)
        for i, v in enumerate(self.vs, self.N0):
            self.seg[i] = (self.depth[v], v)
        for i in range(self.N0-1, 0, -1):
            self.seg[i] = min(self.seg[2*i], self.seg[2*i+1])
    
    def _query(self, l, r):
        res = self.INF
        l += self.N0
        r += self.N0
        while l < r:
            if r & 1:
                res = min(res, self.seg[r-1])
            if l & 1:
                res = min(res, self.seg[l])
                l += 1
            l >>= 1
            r >>= 1
     
        return res

    def query(self, u, v):
        fu, fv = self.firstVisited[u], self.firstVisited[v]
        if fu > fv:
            fu, fv = fv, fu
        return self._query(fu, fv+1)[1]

n, q = map(int, input().split())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c, d = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append((b, c, d))
  T[b].append((a, c, d))
G = [[] for _ in range(n)]
edge = [[] for _ in range(n)]
stack = [(0, -1)]
while stack:
  v, par = stack.pop()
  for nv, c, d in T[v]:
    if nv == par:
      continue
    G[v].append((nv, c, d))
    edge[v].append(nv)
    stack.append((nv, v))

seg = LCA(edge, 0)
A = [0]*q
C = [[] for _ in range(n)]
num = [0]*n
cum = [0]*n
for i in range(q):
  x, y, u, v = map(int, input().split())
  u -= 1
  v -= 1
  a = seg.query(u, v)
  C[u].append((i, x, y, 1))
  C[v].append((i, x, y, 1))
  C[a].append((i, x, y, -2))
dist = 0
stack = [0]
def dfs(v):
  global dist
  for i, x, y, b in C[v]:
    A[i] += (dist + num[x]*y - cum[x]) * b
  for nv, c, d in G[v]:
    dist += d
    num[c] += 1
    cum[c] += d
    dfs(nv)
    dist -= d
    num[c] -= 1
    cum[c] -= d
dfs(0)
print(*A, sep="\n")

Measured memory_bytes: 810880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b,x;
  cin >> a >> b >> x;
  const double pai=3.1415926535897932;
  if(a*a*b/2.0 <= x){
  const double m = 2*(a*a*b-x)/(a*a);
  cout << fixed << setprecision(12) << atan(m/a)*180.0/pai << endl;}
  else{const double m = 2*x/(a*b);
      cout << fixed << setprecision(12) << atan(b/m)*180.0/pai << endl;;}
  
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

ll power(ll x ,int n)
{
    if(n==0)return 1;
    
    ll y=power((x*x)%mod,n/2);
    if(n%2)y*=x;
    return y%mod;
}

int main() {
	int n,i,j;
	cin>>n;
	int arr[n];
	map<int,int> mp;
	for(i=0;i<n;i++)
	{
	    cin>>arr[i];
	    int m=arr[i];
	    for(j=2;j*j<=arr[i];j++)
	    {
	        int cnt=0;
	        if(arr[i]%j==0)
	        {
	            while(m%j==0)
	            {
	                m/=j;
	                cnt++;
	            }
	            mp[j]=max(mp[j],cnt);
	        }
	           
	    }
        if(m!=1)mp[m]=max(mp[m],1);
	}
	
	ll lcm=1;
	for(auto &z:mp)
	{
	    //cout<<z.first<<' '<<z.second<<'\n';
	    while(z.second--)
	    {
	        lcm*=z.first;
	        lcm%=mod;
	    }
	}
	ll ans=0;
	for(i=0;i<n;i++)
	{
	    ll x=lcm*power(arr[i],mod-2);
	    ans+=x%mod;
	}
	cout<<ans%mod;
	
	
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, a[N], b[N], c[N];
int dp[N][4];
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d%d%d", &a[i], &b[i], &c[i]);

    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for(int i = 2; i <= n; ++i){
        for(int j = 1; j <= 3; ++j){
            int add = 0;
            for(int k = 1; k <= 3; ++k){
                if(k != j)
                    add = max(add, dp[i-1][k]);
            }
            dp[i][j] = (j == 1? a[i]:0) + (j == 2?b[i]:0) + (j == 3?c[i]:0) + add;
        }
    }
    int ans = -1;
    for(int j = 1; j <= 3; ++j)
        ans = max(dp[n][j], ans);
    printf("%d", ans);
    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
int factor(int x){
    if(x%4==0) return 4;
    else if(x%2==0) return 2;    
    else return 0;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
map<int,int>facts;
rep(i,n){
    cin>>a[i];
    facts[factor(a[i])]++;
}
if(facts[2]==n){
    cout<<"Yes"<<endl;
}
else{
    if(facts[2]>0)facts[0]++;

    if(facts[0]<=facts[4]+1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}
return 0;
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x, y, z = na()
print(z, x, y)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

vec modcomb(ll n, ll k, ll m)
{
    vec c(k+1, 0), inv(k+1, 0);
    inv[1] = 1;
    c[0] = 1; c[1] = n;
    REP(i,2,k+1) {
        inv[i] = m - inv[m%i] * (m / i) % m;
        c[i] = (((c[i-1] * (n - i + 1)) % m) * inv[i]) % m;
    }
    return c;
}


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

    vec C = modcomb(N, MAX(A, B), MOD);
    PR(((modpow(2,N,MOD)-(C[A]+C[B]+1))%MOD+MOD)%MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 6340
import java.awt.peer.SystemTrayPeer;
import java.util.*;

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

		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int sy = sc.nextInt()-1;
		int sx = sc.nextInt()-1;
		
		char[][] text = new char[2][];
		text[0] = sc.next().toCharArray();
		text[1] = sc.next().toCharArray();
		
		int[][][] move = new int[2][2][N];
		
		for(int i=0; i<N; i++) {
			for(int j=0; j<2; j++) {
				switch(text[j][i]) {
				case 'U':
					move[0][j][i] = -1;
					break;
				case 'D':
					move[0][j][i] = 1;
					break;
				case 'L':
					move[1][j][i] = -1;
					break;
				case 'R':
					move[1][j][i] = 1;
					break;
				}
			}
		}
		
		if(check(H, sy, move[0][0], move[0][1]) || check(W, sx, move[1][0], move[1][1])) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
		
		sc.close();
	}
	
	static boolean check(int LEN, int p, int[] s, int[] t) {
		int cur = p;
		for(int i=0; i<s.length; i++) {
			if(s[i]==-1) {
				cur--;
				if(cur<0)
					return true;
			}
			if(t[i]==1 && cur<LEN-1)
				cur++;
		}
		cur = p;
		for(int i=0; i<s.length; i++) {
			if(s[i]==1) {
				cur++;
				if(cur>=LEN)
					return true;
			}
			if(t[i]==-1 && cur>0)
				cur--;
		}
		return false;
	}
}


Measured memory_bytes: 32048
def nCk(n,k):
    if n<k or (n<0 or k<0):
        return 0
    #k=min(k,n-k)
    num,denum=1,1
    for i in range(k):
        num=num*(n-i)%mod
        denum=denum*(i+1)%mod
    return num*pow(denum,mod-2,mod)%mod

x,y=map(int,input().split())
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print(0)
else:
    m=(y+x)//3
    l=int(n)
    print(nCk(m,l))

Measured memory_bytes: 3064
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N = int(input())
P = primes(55555)
ans = []
for p in P:
    if len(ans) == N:
        break
    if p % 5 == 1:
        ans.append(p)

print(*ans)

Measured memory_bytes: 3572
#include <cstdio>

#define MAX 1000000

bool prime[MAX] = {true};
int p[10000] = {0};

void eratos(void);

int main(void)
{
	eratos();
	
	int n, sum;
	
	while (scanf("%d", &n)){
		if (n == 0) break;
		
		sum = 0;
		for (int i = 0; i < n; i++){
			sum += p[i];
//			printf("p[i] : %d\n", p[i]);
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

void eratos(void)
{
	int pnum = 0;
	for (int i = 0; i < MAX; i++) prime[i] = true;
	for (int i = 2; pnum < 10000; i++){
		if (prime[i]){
			p[pnum++] = i;
			for (int j = 2; i * j < MAX + 1; j++){
				prime[i * j] = false;
			}
		}
	}
	return;
}

Measured memory_bytes: 0
a = [input().split() for _ in range(3)]
n = int(input())
b = [input() for _ in range(n)]

if n <= 2:
  print("No")
  exit()

for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i] == a[j][k]:
        a[j][k] = "x"

for i in range(3):
  if len(set(map(tuple, a[i]))) == 1:
    print("Yes")
    exit()
a_0 = []
a_1 = []
a_2 = []
for i in range(3):
  a_0.append(a[i][0])
  a_1.append(a[i][1])
  a_2.append(a[i][2])

a_rcross = []
a_lcross = []
for i in range(3):
  a_rcross.append(a[i][i])
  a_lcross.append(a[i][2-i])
if len(set(map(tuple, a_0))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_1))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_2))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_rcross))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_lcross))) == 1:
    print("Yes")
    exit()
    
print("No")

Measured memory_bytes: 38384
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll n,k,i;
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
    return 0;
}





Measured memory_bytes: 3576
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def Z_algorithm(S):
    l=len(S)
    A=[0]*l
    A[0]=l
    i=1; j=0
    while i<l:
        while i+j<l and S[j]==S[i+j]:
            j+=1
        if not j:
            i+=1
            continue
        A[i]=j
        k=1
        while l-i>k<j-A[k]:
            A[i+k]=A[k]
            k+=1
        i+=k; j-=k
    return A

def jugde(W):
    Z=Z_algorithm(W)
    l=len(W)
    B=[True]*l
    for p in range(1,l):
        if not B[p-1]:
            continue
        k=2
        while (k-1)*p<=Z[p]:
            B[k*p-1]=False
            k+=1
    return B

def solve(W):
    n=len(W)
    if len(set(W))==1:
        print(n)
        print(1)
        return
    G=jugde(W)
    W.reverse()
    G_rev=jugde(W)
    if G[-1]:
        print(1)
        print(1)
        return
    print(2)
    cnt=0
    for i in range(n-1):
        cnt+=G[i] and G_rev[-(i+2)]
    print(cnt)
    return

solve(list(input()))

Measured memory_bytes: 94760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        //int n = cin.NextInt();
        //int m = cin.NextInt();
        //int[] s = new int[n];
        //int[] t = new int[n];

        //for (int i = 0; i < n; i++)
        //{
        //    s[i] = cin.NextInt();
        //}
        //for (int i = 0; i < m; i++)
        //{
        //    t[i] = cin.NextInt();
        //}

        int a = cin.NextInt();
        int b = cin.NextInt();

        if (b % a == 0)
        {
            Console.WriteLine(a + b);
        }
        else
        {
            Console.WriteLine(b - a);
        }

    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 13140
#include <utility>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
using namespace std;

#define y0 y910831
#define y1 y923456
#define j0 j771912
#define j1 j442401
#define next next18181
#define prev prev18181

using ll = long long;
using ul = unsigned long;
#define INF 1LL<<60
#define PRIME 1000000007
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, 1, -1};
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt[]={0,0,0,0};
	
	ll a;
	REP(i,6){
		cin >> a;
		cnt[a-1]++;
	}
	REP(i,4){
		if(cnt[i]>2){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}


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

typedef pair<long long, long long> P;

struct edge {
	long long From;
	long long To;
	long long Cost;
};

int main() {
	long long N, M, INF = 1000000000000000000;
	static long long Dist[500000] = {};
	static vector<P> V[500000];
	static vector<long long> VL;
	static vector<edge> VE;
	deque<P> DQ;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		long long P, Q, C;
		cin >> P >> Q >> C;
		P--, Q--;
		if (P > Q) swap(P, Q);
		long long R = C * 100000 + P, S = C * 100000 + Q;
		VL.push_back(R), VL.push_back(S);
		VE.push_back({ P, R, 0 });
		VE.push_back({ R, P, 1 });
		VE.push_back({ R, S, 0 });
		VE.push_back({ S, R, 0 });
		VE.push_back({ S, Q, 1 });
		VE.push_back({ Q, S, 0 });
	}
	sort(VL.begin(), VL.end());
	VL.erase(unique(VL.begin(), VL.end()), VL.end());
	for (edge E : VE) {
		if (E.From >= 100000) {
			E.From = lower_bound(VL.begin(), VL.end(), E.From) - VL.begin() + N;
		}
		if (E.To >= 100000) {
			E.To = lower_bound(VL.begin(), VL.end(), E.To) - VL.begin() + N;
		}
		V[E.From].push_back({ E.To, E.Cost });
	}
	for (int i = 0; i < VL.size() + N; i++) {
		sort(V[i].begin(), V[i].end());
		V[i].erase(unique(V[i].begin(), V[i].end()), V[i].end());
		Dist[i] = INF;
	}
	DQ.push_back({ 0, 0 });
	while (!DQ.empty()) {
		P p = DQ.front();
		DQ.pop_front();
		if (p.first == N - 1) {
			cout << p.second << endl;
			return 0;
		}
		if (Dist[p.first] <= p.second) continue;
		Dist[p.first] = p.second;
		for (P np : V[p.first]) {
			if (Dist[np.first] == INF) {
				if (np.second == 0) DQ.push_front({ np.first, p.second });
				else DQ.push_back({ np.first, p.second + 1 });
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vi x_(n), y_(n), h_(n);
	int cnt = 0;
	int si = -1;
	rep(i, n) {
		cin >> x_[i] >> y_[i] >> h_[i];
		if (h_[i] > 0) si = i;
	}

	for (int y = 0; y <= 100; ++y) {
		for (int x = 0; x <= 100; ++x) {
			ll h = abs(x_[si] - x) + abs(y_[si] - y) + h_[si];
			bool ok = true;
			for (int k = 0; k < n; ++k) {
				if (h_[k] > 0 && h - h_[k] != abs(x_[k] - x) + abs(y_[k] - y)) {
					ok = false;
				}
				else if (h_[k] == 0 && h > abs(x_[k] - x) + abs(y_[k] - y)) {
					ok = false;
				}
			}
			if (ok) {
				cout << x << " " << y << " " <<  h << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int m, k;
signed main() {
	cin >> m >> k;
	if ((1 << m) - 1 < k || (m == k && m == 1)) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 0) {
		for (int i = 0; i < (1 << m); i++) {
			if (i == 0)
				cout << i << " " << i;
			else cout << " " << i << " " << i;
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < (1 << m); i++) {
		if (i != k)
			cout << i << " ";
	}
	cout << k << " ";
	for (int i = (1 << m) - 1; i >= 0; i--) {
		if (i != k) {
			cout << i << " ";
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 1792
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
while n<=k:
    s+=1
    n*=2
print(s)

Measured memory_bytes: 13604
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n,m;

int main()
{

	cin >> n >> m;
	if(n == m) cout << "Yes";
	else cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Map<Integer, Integer> h = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            if (h.containsKey(a[i])) {
                h.put(a[i], h.get(a[i]) + 1);
            } else {
                h.put(a[i], 1);
            }
        }
        List<Integer> max4 = h.entrySet().stream().filter(x -> x.getValue() >= 4).map(x -> x.getKey())
                .collect(Collectors.toList());
        List<Integer> max2 = h.entrySet().stream().filter(x -> x.getValue() >= 2).map(x -> x.getKey())
                .collect(Collectors.toList());
        long ans = 0;
        if (max4.size() > 0) {
            ans = (long) max4.get(0) * max4.get(0);
        }
        if (max2.size() > 1) {
            ans = Math.max(ans, (long) max2.get(0) * max2.get(1));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48284
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    n = int(S.replace(' ', ''))

    for i in range(1, 10000):
        if i * i == n:
            print('Yes')
            return

    print('No')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
from collections import Counter
N = int(input())
L = Counter(int(i) for i in input().split())
maxL = max(L)
key = sorted(L.keys())
val = [L[i] for i in range(1, max(L) + 1)]
acc = [0] * (len(val) + 1)
for i in range(len(val)):
    acc[i + 1] = acc[i] + val[i]
cnt = 0
for a in key:
    cnt += L[a] * (L[a] - 1) * (L[a] - 2) // 6
    cnt += max(acc[min(2 * a - 1, maxL)] - acc[a], 0) * L[a] * (L[a] - 1) // 2
for i in range(len(key) - 1):
    for j in range(i + 1, len(key)):
        a, b = key[i], key[j]
        cnt += L[a] * L[b] * (L[b] - 1) // 2
for i in range(len(key) - 2):
    for j in range(i + 1, len(key) - 1):
        a, b = key[i], key[j]
        cnt += max(acc[min(a + b - 1, maxL)] - acc[b], 0) * L[a] * L[b]
print(cnt)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	sort(A.begin(),A.end());
	int ret=0;
	for (int i=0; i<K; i++)
		ret+=A[i];
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int myabs(int n)
{
	return n>0?n:-n;
}

int main()
{
	int n, i;
	scanf("%d", &n);
	int flag = 1;
	int t0 = 0, x0 = 0, y0 = 0;
	for(i=0;i<n;i++)
	{
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		int dt = myabs(t-t0);
		int dx = myabs(x-x0);
		int dy = myabs(y-y0);
		if((dx+dy)%2!=dt%2)
			flag = 0;
		else if((dx+dy)>dt)
			flag = 0;
		t0 = t;
		x0 = x;
		y0 = y;
	} 
	if(flag)
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define fst first
#define scd second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 100000
//---------------------

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << *ite << " ";return os;}

string s;

int main(){
	cin>>s;
	char lastnum;
	bool isbad=false;
	REP(i,4){
		if(i==0) {lastnum=s[0];continue;}
		if(s[i]==lastnum) isbad=true;
		lastnum=s[i];
	}
	if(isbad) cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll k;
G g;
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld%lld",&n,&k);
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}



//dfs
ll deg[100010];
ll dfs(int v,int pre){
	int cnt=0;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			//hoge
			cnt++;
			dfs(g.e[i].g,v);
		}
	}
	deg[v]=cnt;
}

ll fact[100010];
ll perm(ll n,ll r){
	if(r>n)return 0;
	return fact[n]*invp(fact[n-r],MOD)%MOD;
}

int main(){
	readgraph();
	fact[0]=1;
	rep(i,1,100005)fact[i]=fact[i-1]*i%MOD;
	dfs(0,-1);
	ll ans=k*perm(k-1,deg[0])%MOD;
	rep(i,1,g.vcnt){
		ans=ans*perm(k-2,deg[i])%MOD;
	}
	printf("%lld",ans);
}

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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

int main() {
	int n,m,c;
	cin>>n>>m>>c;
	int b[m];
	for(int i=0;i<m;i++){
	    cin>>b[i];
	}
	int count=0;
	int a[n][m];
	for(int i=0;i<n;i++){
	    ll sum=0;
	    for(int j=0;j<m;j++){
	        int x;
	        cin>>x;
	        sum+=x*b[j];
	    }
	    if(sum+c>0)
	    count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
    int n;
    int i;
    long x[100];
    long y[100];
    int p;
    double p2,p3;
    double ans0,ans1,ans2,ans_max;
    double temp1;
    
    cin >> n;
    
    for ( i = 0; i < n;++i ){
        cin >> x[i];
    }
    for ( i = 0; i < n;++i ){
        cin >> y[i];
    }
    
    /*
    cout << " "  << n << endl;
    
    for ( i = 0; i < n; ++i ){
        cout << " " << x[i];
    }
    cout << endl;
    
    for ( i = 0; i < n; ++i ){
        cout << " "<< y[i];
    }
    cout << endl;
    cout << endl;
    */

    ans0 = 0;
    ans1 = 0;
    ans2 = 0;
    ans_max = 0;
    temp1= 0;
    
    for ( i = 0; i < n; ++i ){
        temp1 = abs(x[i]-y[i]);
        if (ans_max < temp1)ans_max=temp1;
        ans0 = ans0 + temp1;
        ans1 = ans1 + pow(temp1,2);
        ans2 = ans2 + pow(temp1,3);
        //cout << endl;
    }
    
    p2 = 1.0 / 2.0;
    p3 = 1.0 / 3.0;
    
    ans1 = pow(ans1,p2);
    ans2 = pow(ans2,p3);
    
    //printf("%-20.6f\n",p2);
    //printf("%-20.6f\n",p3);
    printf("%-20.6f\n",ans0);
    printf("%-20.6f\n",ans1);
    printf("%-20.6f\n",ans2);
    printf("%-20.6f\n",ans_max);
    
    return 0;
}

Measured memory_bytes: 3344
#include<stdio.h>

int main(int argc, char* argv[]){
	int h,w,n;
	scanf("%d", &h);
	scanf("%d", &w);
	scanf("%d", &n);
	int black = 0;
	int op = 0;
	
	if(h < w){
		h = w;
	}
	while(n>black){
		black+=h;
		op++;
	}
	printf("%d\n", op);
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  auto make_left = [&] (const auto& a) {
    std::vector<std::vector<int>> left(n + 1, std::vector<int>(k + 1, false));
    left.at(0).at(0) = true;
    for (int i = 0; i < n; i++) {
      auto& crr = left.at(i);
      auto& nxt = left.at(i + 1);
      nxt = crr;
      for (int x = 0; x + a.at(i) <= k; x++) {
        nxt.at(x + a.at(i)) |= crr.at(x);
      }
    }
    return left;
  };
  auto left  = make_left(a);
  auto right = [&]{
    auto b = a;
    std::reverse(b.begin(), b.end());
    auto ret = make_left(b);
    std::reverse(ret.begin(), ret.end());
    return ret;
  }();
  auto search = [&] (int x, const auto& l, const auto& r) {
    for (int i = k - 1; i >= 0;) {
      if (l.at(i)) {
        for (int j = std::max(0, k - x - i); j < k - i; j++) {
          if (r.at(j)) return true;
        }
        i -= x;
      } else {
        i--;
      }
    }
    return false;
  };
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret += !search(a.at(i), left.at(i), right.at(i + 1));
  }
  std::cout << ret << std::endl;
  return 0;
}

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

int main(){
    int n, d ,x;
    cin >> n >> d >> x;

    vector<int> a(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += (d-1) / a[i] + 1;
    }
    cout << sum + x << endl;
    return 0;
}

Measured memory_bytes: 256
def ans():
  N = int(input())
  T, A = map(int,input().split())
  H = list(map(int,input().split()))
  res = 1e9
  for h in H:
    x = abs(T-h*0.006-A)
    if(res > x):
      res = x
      tmp = h
  print(H.index(tmp)+1)
ans()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int INF = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    vector<LL> a(N);
    int min = INF;
    REP(i,N)
    {
        LL tmp;
        cin >> tmp;
        a[i] = tmp - i - 1;
        dump(a[i])
        if(a[i] < min) min = a[i];
    }
    if(min < 0)
    {
        REP(i,N)
        {
            a[i] -= min;
            dump(a[i])
        }
    }
    sort(a.begin(), a.end());
    int ave;
    ave = a[N/2];
    LL res = 0;
    REP(i,N)
    {
        res += abs(a[i] - ave);
    }
    cout << res << endl;

}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    string s; cin >> s;
    REP(i,s.size()){
        int max_c = (int)'Z';
        int new_c = (int)s[i] + n;
        if(new_c>max_c) new_c-=26;
        s[i] = (char)new_c;
    }
    cout << s << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
	char s[8];
	
	scanf("%s", s);

	if (s[0] == s[1] && s[1] == s[2]) {
		printf("Yes\n");
	} else if (s[1] == s[2] && s[2] == s[3]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int H,W; cin >> H >> W;
    int h,w; cin >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

struct node {
    int val;
    struct node *prev;
    struct node *next;
};

struct node *nil;

void init() {
    nil = (struct node*) malloc( sizeof(struct node) );
    nil->prev = nil;
    nil->next = nil;
}

void insertVal(int d) {
    struct node *x;
    x = (struct node*) malloc( sizeof(struct node) );
    x->val = d;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void deleteVal(int d) {
    struct node *cur;
    cur = nil->next;
    while (cur != nil) {
        if (cur->val == d) {
            cur->prev->next = cur->next;
            cur->next->prev = cur->prev;
            break;
        } else {
            cur = cur->next;
        }
    }
}

void deleteFirst() {
    nil->next->next->prev = nil;
    nil->next = nil->next->next;
}

void deleteLast() {
    nil->prev->prev->next = nil;
    nil->prev = nil->prev->prev;
}

void printList() {
    struct node *cur = nil->next;
    int isf = true; // is it first?
    while (true) {
        if ( cur == nil ) break;
        if ( isf == false )  cout << " ";
        cout << cur->val;
        cur = cur->next;
        isf = false;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    int sl; // size of list
    init();
    string s;
    for (int i=0; i<n; i++) {
        cin >> s;
        int d;
        if (s == "insert") {
            cin >> d;
            insertVal(d);
        } else if (s == "delete") {
            cin >> d;
            deleteVal(d);
        } else if (s == "deleteFirst") {
            deleteFirst();
        } else if (s == "deleteLast") {
            deleteLast();
        }
    }
    printList();
}


Measured memory_bytes: 37532
from functools import reduce
import fractions
# import math


def gcd_lst(lst):
    return reduce(fractions.gcd, lst)
    # return reduce(math.gcd, lst)

    
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
max_A = max(lst_A)
gcd_A = gcd_lst(lst_A)

ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

print(ans)

Measured memory_bytes: 16304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int a, b, c;
    string ans = "No";
    cin >> a >> b >> c;
    if (a < b && b < c) ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 3152
#include<stdio.h>

int main(){
  
  int H,W;
  int sum = 0;
  scanf("%d %d",&H,&W);

  char S[H][W];
  int Ans[52][52] = {0};
  for(int i=0; i<H; i++){
      scanf("%s",S[i]);
  }

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if(S[i][j] == '#'){

          for(int k=-1; k<=1; k++){
            for(int l=-1; l<=1; l++){
              Ans[i+1+k][j+1+l]++;

            }
          }
        }

    }
  }

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j] == '#'){
        printf("#");
      }else{
        printf("%d",Ans[i+1][j+1]);
      }
      }
      printf("\n");
  }

  return 0;

}

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

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}

const int N=101000,ae=20;
struct Edge{int v,nxt;}a[N*ae*2];
int qx[N*ae],qy[N*ae],dad[N];
int head[N],_,sz[N];
int n,he=1,ta=0;

inline int find(int x){return dad[x]?dad[x]=find(dad[x]):x;}

inline void ins(int u,int v){++sz[u],a[++_].v=v,a[_].nxt=head[u],head[u]=_;}

map <ll,int> cnt;

#define h(x,y) (x+1ll*n*y)
inline void add(int x,int y){
	if(x>y)swap(x,y);
	ins(x,y),ins(y,x);
	if((++cnt[h(x,y)])==2)
		++ta,qx[ta]=x,qy[ta]=y;
}

int main(){
	read(n);int x,y,p;
	for(rg int i=n-2+n;i;--i)read(x),read(y),add(x,y);
	for(rg int i=1;i<n;++i){
		do	x=qx[he],y=qy[he],++he;
		while(find(x)==find(y)&&he<=ta);
		x=find(x),y=find(y);
		if(x==y){puts("NO");return 0;}
		if(sz[x]>sz[y])swap(x,y);
		--sz[y];cnt.erase(x<y?h(x,y):h(y,x));
		for(rg int j=head[x];j;j=a[j].nxt){
			p=find(a[j].v);
			if(p^y)if(p!=find(x))add(p,y);
		}
		dad[x]=y;
	}puts("YES");
}

Measured memory_bytes: 26880
import sys
import collections
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = II()
    n = N
    ans = 0

    if N == 0 or N == 1:
        print(0)

    else:
        numl = prime_factorize(N)
        j = len(set(numl))
        setl = list(set(numl))
        c = collections.Counter(numl)

        for i in setl:
            #print(i,c[i])
            k = 1
            ci = c[i]
            while True:
                if ci-k>=0:
                    ans += 1
                else:
                    break
                ci = ci-k
                k += 1


        print(ans)

        """
        for i in range(2,N+1):
            if n % i == 0:
                n = n/i
                ans += 1
            if n == 1:
                break
        print(ans)
        """

    


if __name__ == "__main__":
	main()

Measured memory_bytes: 67780