akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int clr[505][505];
string s[505];

#define R 4
#define B 3
#define P 2

 main()

{
    fast
    int h,w;
    cin>>h>>w;
    cin.ignore();
    f(i,0,h-1)
    {
        cin>>s[i];
        f(j,0,w-1)
        {
            if(s[i][j]=='#')clr[i][j]=P;
        }
    }
    f(i,0,h-1)
    {
        f(j,0,w-1)
        {
            if(j==0){clr[i][j]=R;continue;}
            if(j==w-1){clr[i][j]=B;continue;}
            if(i%2==0 && clr[i][j]!=P)
            {
                clr[i][j]=R;
            }
            else if(clr[i][j]!=P) clr[i][j]=B;
        }
    }
    f(i,0,h-1)
    {
        f(j,0,w-1)
        {
            if(clr[i][j]==R || clr[i][j]==P)
            {
                cout<<"#";
            }
            else cout<<".";
        }
        cout<<endl;
    }
    cout<<endl;
     f(i,0,h-1)
    {
        f(j,0,w-1)
        {
            if(clr[i][j]==B || clr[i][j]==P)
            {
                cout<<"#";
            }
            else cout<<".";
        }
        cout<<endl;
    }
    return 0;

}













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

struct node {
  node *ch[2];
  
  node() {
    ch[0] = ch[1] = 0;
  }
  ~node() {
    delete ch[0];
    delete ch[1];
  }
};

void tostr(node *nd, string &s) {
  if(nd) {
    s += '(';
    tostr(nd->ch[0], s);
    s += ',';
    tostr(nd->ch[1], s);
    s += ')';
  }
}

const char *p;
node *parse() {
  node *ret = new node;
  if(*++p == '(') {
    ret->ch[0] = parse();
  }
  if(*++p == '(') {
    ret->ch[1] = parse();
  }
  ++p;
  return ret;
}

node *child(node *nd, int k) {
  return nd ? nd->ch[k] : 0;
}

node *opr(char type, node *a, node *b) {
  node *ret = 0;
  if (type == 'i') {
    if(a && b) {
      ret = new node;
    }
  }
  else {
    if(a || b) {
      ret = new node;
    }
  }
  
  if (ret) {
    for (int i = 0; i < 2; i++) {
      ret->ch[i] = opr(type, child(a, i), child(b, i));
    }
  }
  return ret;
}

int main() {
  char type;
  string s, t;
  while(cin >> type >> s >> t) {
    node *ns, *nt, *ret;
    p = s.c_str();
    ns = parse();
    p = t.c_str();
    nt = parse();
    
    ret = opr(type, ns, nt);

    string u;
    tostr(ret, u);
    cout << u << endl;

    delete ns;
    delete nt;
    delete ret;
  }
}

Measured memory_bytes: 1192
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int W = nextInt();
        int dp[][] = new int[2][100001];
        Arrays.fill(dp[0], 1000000001);
        Arrays.fill(dp[1], 1000000001);

        int ans = 0;
        for (int i = 1; i <= N; i++) {
            int wi = nextInt();
            int vi = nextInt();
            for (int j = 0; j < 100001; j++) {
                if (i%2 == 1) {
                    if (j <= vi) {
                        dp[1][j] = Math.min(dp[0][j], wi);
                    } else {
                        dp[1][j] = Math.min(dp[0][j], dp[0][j-vi]+wi);
                    }

                    if (dp[1][j] <= W) {
                        ans = Math.max(ans, j);
                    } else {
                        break;
                    }
                } else {
                    if (j <= vi) {
                        dp[0][j] = Math.min(dp[1][j], wi);
                    } else {
                        dp[0][j] = Math.min(dp[1][j], dp[1][j-vi]+wi);
                    }

                    if (dp[0][j] <= W) {
                        ans = Math.max(ans, j);
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}


Measured memory_bytes: 22740
using System;
using System.Linq;
using System.Collections;
using System.Text;
public class c
{
  public static void Main()
  {
    int[] NM=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    long[][] AB=new long[NM[0]][];
    int i;
    for(i=0;i<NM[0];i++)
    {
      long[]x=Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); 
      AB[i]=new long[2];
      AB[i][0]=x[0];
      AB[i][1]=x[1];
    }
     Array.Sort(AB, (a, b) => a[0].CompareTo(b[0]));
    long ans=0;
    long countM=0;
    
    for(i=0;i<NM[0];i++)
    {
      if(countM<=NM[1]-AB[i][1]){ans+=AB[i][0]*AB[i][1];countM+=AB[i][1];}
      else if(countM<NM[1]){ans+=AB[i][0]*(NM[1]-countM);countM+=NM[1]-countM;}
      else break;
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 22832
/*input
1 1
*/
#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 int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m; cin >> n >> m;
    if(n == m) cout << "Yes";
    else cout << "No";

    return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int dist[MAX] , depth[MAX] , P[MAX] ;
int n , u , v ;
vector< vector<int> >adj(MAX) ;

void dfs(int node , int par , int lvl)
{
	P[node] = par ;
	depth[node] = lvl ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		dfs(child , node , lvl+1) ;
		dist[node] = max(dist[node] , dist[child] + 1) ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>u>>v ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	dfs(v , -1 , 0) ;
	int a = depth[u] , b = 0 , cur = u , ans = 0 ;
	while(a-b > 2)
		cur = P[cur] , --a , ++b , ans++ ;
	return cout<<ans+dist[cur]+(a-b == 2)<<"\n" , 0 ;
}		

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    int d = 0;
    for (int i = 0;i < n;i++){
        cin >> l.at(i);
    }
    int count = 1;
    int i = 0;
    for (int i = 0;i < n;i++){
        d = d + l.at(i);
        if (d > x){
            break;
        }
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef string str;

int main(){
  str s;
  cin >> s;
  ll a = 0;
  while(true){
    if(s[a]=='A')break;
    a++;
  }
  ll z = s.length()-1;
  while(true){
    if(s[z]=='Z') break;
    z--;
  }
  cout << z-a+1 << endl;
  return 0;
}


Measured memory_bytes: 640
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
 
n = int(input())
 
count = 0
a = factorization(n)
if n == 1:
  print(0)
  exit()
  
for i in range(len(a)):
  a[i][1] -= 1
  count += 1
  b = 2
  while a[i][1] > 0:
    a[i][1] -= b
    if a[i][1] >= 0:
      count += 1
    b += 1
 
print(count)

Measured memory_bytes: 9440
const log = console.log;

const flatNaive = <T>(arrays: T[][]): T[] => [].concat.apply([], arrays);

// ----

function Main(input: string): void {
  const c = input
    .trim()
    .split("\n")
    .map(s => s.split(" ").map(s => parseInt(s)));

  const flatC = flatNaive(c);
  const minC = Math.min(...flatC);
  const maxC = Math.max(...flatC);

  for (let a0 = minC; a0 <= maxC; a0++) {
    // If we know a[0], other values should also be determined
    const b = [c[0][0] - a0, c[0][1] - a0, c[0][2] - a0];
    const a = [a0, c[1][0] - b[0], c[2][0] - b[0]];

    // Validate excluding a[0]
    let valid = true;

    for (let i = 1; i < 3; i++) {
      for (let j = 0; j < 3; j++) {
        if (c[i][j] !== a[i] + b[j]) {
          valid = false;
          break;
        }
      }

      if (!valid) break;
    }

    if (valid) {
      log("Yes");

      return;
    }
  }

  log("No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  print $ solve n m

solve :: Int -> Int -> Int
solve n m = maximum $ filter (<= m `div` n) $ divisors m

divisors :: Int -> [Int]
divisors m = go 1 m
  where
    go k m
      | k ^ 2 > m = []
      | m `mod` k == 0 = k : m `div` k : go (k + 1) m
      | otherwise = go (k + 1) m


Measured memory_bytes: 508
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n,r;cin>>n>>r;
    if(n>=10){
        cout<<r;
    }else{
        cout<<r+100*(10-n);
    }
}




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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int counter = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i+100*j+50*k==x){
          counter++;
        }
      }
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
fac=[1]*505050
inv=[1]*505050
finv=[1]*505050
mod=1000000007
for i in range(2,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*finv[n-r]*finv[r]%mod

N,M=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(N,i)*fac[M]*finv[M-i]*((fac[M-i]*finv[M-N])**2)*(1 if i%2==0 else -1) % mod
print(ans%mod)

Measured memory_bytes: 102640
import Control.Applicative
import Control.Monad
import Data.List

next x (a:b:as)|x==a = b
next x (a:as) = next x as

eTS :: Int -> Int -> Int
eTS t s = next s fromT
          where fromT = [[1,2,4,3,1],[0,3,5,2,0],[0,1,5,4,0],[0,4,5,1,0],[0,2,5,3,0],[4,2,1,3,4]]!!t

-- TSEWNB
main = do
    label <- words <$> getLine
    q <- readLn
    m <- replicateM q ( (map (\ w -> let (Just a) = findIndex(== w) label in a).words) <$> getLine)
    let a = map (\x -> eTS (x!!0) (x!!1)) m
    putStrLn $ (intercalate "\n".map (label!!)) a

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

void solve()
{
	string S;
	cin>>S;

	if(S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR")
		cout<<1<<endl;	

	else if(S == "RRS" || S == "SRR")
		cout<<2<<endl;

	else if(S == "RRR")
		cout<<3<<endl;

	else
		cout<<0<<endl;
}

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

	// freopen("Input.txt","r",stdin);
	// freopen("Output.txt","w",stdout);

	solve();

	return 0;
} 

Measured memory_bytes: 3596
A, B, K = map(int,input().split())
for i in range(K):
    if i % 2 == 0:
        A -= (A % 2 == 1)
        A, B = A//2, B+A//2
    else:
        B -= (B % 2 == 1)
        A, B = A + B//2, B//2

print(A, B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
const ll MOD = 1000000007;
#define rep(i,n) for (ll i=0; i < (n); i++)
using namespace std;
int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main () {
  int h, w;
  scanf("%d %d", &h, &w);

  struct Cell {
    char c;
    int u, d, l ,r;   // その方向に照らせるマスの個数(自分を含む)
  };
  vector<vector<Cell>> g(h+2, vector<Cell>(w+2, Cell{'#',0,0,0,0})); // 周囲も壁と見なした地図を作る
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      g[i][j].c = getchar();
      if (g[i][j].c != '#' && g[i][j].c != '.') {
        j--;
        continue;
      }
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (g[i][j].c == '#') g[i][j].l = 0;
      else {
        g[i][j].l = g[i][j-1].l + 1;
      }
    }
    for (int j = w; j >= 1; j--) {
      if (g[i][j].c == '#') g[i][j].r = 0;
      else {
        g[i][j].r = g[i][j+1].r + 1;
      }
    }
  }

  for (int j = 1; j <= w; j++) {
    for (int i = 1; i <= h; i++) {
      if (g[i][j].c == '#') g[i][j].u = 0;
      else {
        g[i][j].u = g[i-1][j].u + 1;
      }
    }
    for (int i = h; i >= 1; i--) {
      if (g[i][j].c == '#') g[i][j].d = 0;
      else {
        g[i][j].d = g[i+1][j].d + 1;
      }
    }
  }

  int max = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      const Cell& c = g[i][j];
      if (c.c == '.') {
        int sum = c.u + c.d + c.l + c.r - 3;
        if (sum > max) max = sum;
      }
    }
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 78592
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		long ans=long.MaxValue;
		for(int i = 1;i<=100;i++) {
			long p=0;
			for(int j = 0;j<n;j++) {
				p+=(a[j]-i)*(a[j]-i);
			}
			ans=Min(ans,p);
		}
		Console.WriteLine(ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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


main ()
{
        int W, H,x,y,r,correctcount;
        correctcount=0;
        cin>>W;
        cin>>H;
        cin>>x;
        cin>>y;
        cin>>r;
       if(y<=H-r){
       correctcount++;
       }
       if(x>=r) {
       correctcount++;
       
       }
       if(y>=r){
       correctcount++;
       
       }
       if(x<=W-r){
       correctcount++;       
       }
       if(correctcount==4) {
           cout<<"Yes"<<endl;
       }
       else {
           cout<<"No"<<endl;
       }
}
        


Measured memory_bytes: 3136
#include<iostream>
#include<cmath>
using namespace std;
int Bsearch(int n,int e){
  if(e==1)return 1;
  int s,t;
  s=0;t=e;
  int x=e/2;
  while(t-s>1){
    if(pow(x,n)<e){
      s=x;
    }else if(pow(x,n)>e){
      t=x;
    }else{
      break;
    }
    x=(s+t)/2;
  }
  return x;
}
 
int main(){
  int e;
  while(cin>>e){
    if(e==0)break;
    int x=Bsearch(3,e);
    int y=Bsearch(2,e);
    int minim=1000;
    for(int i=0;i<=x;i++){
      int z=i*i*i;
      for(int j=0;j<=y;j++){
	int x=e-z-j*j;
	if(x<0)break;
	minim=min(minim,i+j+x);
      }
    }
    cout << minim << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			String S = scan.next();
			char[] s = new char[6];
			
			s = S.toCharArray();
			
			if(s[2]==s[3]&&s[4]==s[5]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 23252
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    string ans="No";
    
    for(int i=0;i<=n/4;i++){
        if((n-4*i)%7==0) ans="Yes";
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
xy = [list(map(int, list(input().split()))) for i in range(n)]
sum = 0

def dist(x_1, y_1, x_2, y_2):
  return math.sqrt((x_2 - x_1)**2 + (y_2 - y_1)**2)

for i in range(n):
  for j in range(i, n):
    sum += dist(xy[i][0], xy[i][1], xy[j][0], xy[j][1])

print(sum*2/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long n,p,total;
long long arr[200001];
long long power(long long x,long long y){
    long long ans=1;
    x%=p;
    while (y>0){
        if (y%2==1) ans=(ans*x)%p;
        y/=2;
        x=(x*x)%p;
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++) cin>>arr[i];
    p=1e9+7;
    sort(arr,arr+n);
    reverse(arr,arr+n);
    long long x=power(2,n*2-1);
    long long y=x;
    y*=500000004;
    y%=p;
    for (int i=0;i<n;i++){
        total+=arr[i]*x;
        total%=p;
        x+=y;
        x%=p;
    }
    cout<<total;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll x;
    cin >> x;
    ll ans = 2 * (x / 11);
    x -= 11 * (x / 11);

    if (x >= 7) {
        ans += 2;
    } else if (x > 0) {
        ans++;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
n = int(input())
record = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for _ in range(n):
    b, f, r, v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1] += v
for b in range(4):
    for f in record[b]:
        print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("#" * 20)


Measured memory_bytes: 5608
N, A, B, C = map(int, input().split())
takes = []
for i in range(N):
    takes.append(int(input()))
#  g = [100,90,80]
#  takes = [98, 40, 30, 21, 80, 0,0,0]
takes = takes+[0,0,0,0,0,0,0]
takes = takes[:8]
g = [A, B, C]
combis = []
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    for n in range(4):
                        for o in range(4):
                            for p in range(4):
                                #  print(i,j,k,l,m,n,o,p)
                                combis.append([i,j,k,l,m,n,o,p])
#  print(combis)
min_diff = 10**10
for combi in combis:
    A,B,C = 0,0,0
    for idx, el in enumerate(combi):
        if el == 0:
            A += takes[idx]
        elif el == 1:
            B += takes[idx]
        elif el == 2:
            C += takes[idx]

        if A == 0 or B == 0 or C == 0:
            continue

        A_diff = abs(g[0] - A) + (len([_ for _ in combi if _ == 0]) - 1)*10
        B_diff = abs(g[1] - B) + (len([_ for _ in combi if _ == 1]) - 1)*10
        C_diff = abs(g[2] - C) + (len([_ for _ in combi if _ == 2]) - 1)*10
        diff = A_diff + B_diff + C_diff
        min_diff = min(diff, min_diff)

print(min_diff)


Measured memory_bytes: 12788
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, i;
    n = sc.nextInt();

    System.out.print(n + ":");
    for(;n != 1;){
      for(i = 2;i * i < (n + 1);i++){
        if(n % i == 0){
          System.out.print(" " + i);
          n = n / i;
          break;
        }
      }
      if(i * i > n){
        System.out.print(" " + n);
        break;
      }
    }
    System.out.println();
/*end*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17324
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();

    let mut count = vec![0;26];

    for i in 0..n {
        let mut t: String = sc.cin();
        let s = (t.remove(0) as usize) - ('A' as usize);
        count[s] += 1;
    }
    count.sort();

    let mut ans = 0;

    loop {
        // trace!(count);
        let mut kk = 0;
        for i in (0..26).rev() {
            if count[i] > 0 {
                kk += 1;
                count[i] -= 1;
            } else {
                break
            }
            if kk >= k {
                break
            }
        }
        if kk >= k {
            ans += 1;
        } else {
            break;
        }
        count.sort();
    }

    println!("{}", ans);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


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

long get_attacks_to_kill(long hp)
{
  if (hp == 1)
    return 1;
  return 1 + 2 * get_attacks_to_kill(hp / 2);
}

int main()
{
  long H;
  cin >> H;
  cout << get_attacks_to_kill(H) << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m, l := iScan(), iScan(), iScan()
	e := make([][]int, n)
	f := make([][]int, n)
	for i := 0; i < n; i++ {
		e[i] = make([]int, n)
		f[i] = make([]int, n)
		for j := 0; j < n; j++ {
			if i != j {
				e[i][j] = mod
			}
		}
	}
	for i := 0; i < m; i++ {
		a, b, c := iScan()-1, iScan()-1, iScan()
		e[a][b], e[b][a] = c, c
	}
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				e[i][j] = smaller(e[i][j], e[i][k]+e[j][k])
			}
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if e[i][j] <= l && i != j {
				f[i][j] = 1
			} else if i != j {
				f[i][j] = mod
			}
		}
	}
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				f[i][j] = smaller(f[i][j], f[i][k]+f[j][k])
			}
		}
	}
	q := iScan()
	for i := 0; i < q; i++ {
		s, t := iScan()-1, iScan()-1
		if f[s][t] >= mod {
			fmt.Println(-1)
		} else {
			fmt.Println(f[s][t] - 1)
		}
	}
}


Measured memory_bytes: 5012
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	swap(a, b);

	char out[100][101];
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++)
			out[i][j] = '.';
		out[i][100] = 0;
	}
	for (int i = 50; i < 100; i++) {
		for (int j = 0; j < 100; j++)
			out[i][j] = '#';
		out[i][100] = 0;
	}
	for (int i = 0; i < (a - 1); i++)
		out[i / 50 * 2][i % 50 * 2] = '#';
	for (int i = 0; i < (b - 1); i++)
		out[99 - i / 50 * 2][i % 50 * 2] = '.';

	printf("100 100\n");
	for (int i = 0; i < 100; i++)
		printf("%s\n", out[i]);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int dp[100005],h[100005];
int main()
{
    //freopen("C://Code//input.txt","r",stdin);
    int n;scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",h+i);
    dp[1] = abs(h[0]-h[1]);
    for(int i=2;i<n;++i){
        scanf("%d",h+i);
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",dp[n-1]);
    return 0;
}


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

priority_queue<int,vector<int>,greater<int> >q[2];

int main(){
	long long n,m,a,b,c,d=0,s=0;
	cin>>n>>m>>a;
	for(int i=1;i<m;i++){
		cin>>b;
		q[0].push(min(a,b)-1);
		q[1].push(max(a,b)-1);
		a=b;
	}
	for(int i=0;i<n-1;i++){
		while(!q[0].empty()){
			if(q[0].top()!=i)break;
			d++;
			q[0].pop();
		}
		while(!q[1].empty()){
			if(q[1].top()!=i)break;
			d--;
			q[1].pop();
		}
		cin>>a>>b>>c;
		s+=min(a*d,c+(b*d));
	}
	cout<<s<<endl;
	return 0;
}

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

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

using namespace std;

int main(){
	int a,b; scanf("%d%d",&a,&b);
	for(int x=1;x<1e5;x++) if((int)(x*0.08)==a && (int)(x*0.1)==b) return printf("%d\n",x),0;
	puts("-1");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
t = input()

ln = 0
ch = 0
for i in range(len(s)):
    k = 0
    for j in range(i,len(s)):
        if(s[j]==t[k]):
            k += 1
            if(j==len(s)-1):
                ch = 1
                break
        else:
            if(j<len(s)-1):
                k = 0
            
    if(ch==1):
        ln = k
        break

ans  = n + (n-k)

print(ans)

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

const int N = 1000005;
const int mod = (int) 998244353;

int n, mx;
#define ll long long
#define int ll
int a[N];
int cnt[N];
int ans[N];
long long inv[N];

void init() {
    inv[0] = inv[1] = 1;
    for (int i = 2; i < N; i++) {
        inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    }
}

ll modexpo(ll a , ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b&1)
            res = (res*a)%mod;
        a=(a*a)%mod;
        b >>=1;
    }
    return res;
}

int solve(int g) {
    long long sum = 0, res = 0;
    for (int i = g; i <= mx; i += g) {
        (sum += cnt[i] * 1LL * i % mod) %= mod;
    }
    for (int i = g; i <= mx; i += g) {
        (res += cnt[i] * 1LL * i % mod * sum % mod) %= mod;
    }
    (res *= inv[g]) %= mod;
    for (int i = 2 * g; i <= mx; i += g) {
        res -= ans[i] * 1LL * i % mod * inv[g] % mod;
        if (res < 0)
            res += mod;
    }
    return ans[g] = res;
}

signed main() {
    init();
    int t;
    t = 1;
    while (t--) {
        scanf("%d", &n);
        memset(cnt, 0, sizeof cnt);
        memset(ans, 0, sizeof ans);
        mx = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d", a + i);
            cnt[a[i]]++;
            mx = max((ll)mx, a[i]);
        }
        int res = 0;
        for (int g = mx; g > 0; g--) {
            (res += solve(g)) %= mod;
        }
        for (int i = 0 ; i < n ; i++)
            res = (((res - a[i]) % mod + mod)) % mod;
        res = (res * modexpo(2 , mod - 2)) % mod;
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 26880
#include <iostream>

///using namespace std;

/*static*/ const int MAX = 500000;
int H;

void maxHeapify(int *arr, int i)
{
	int l = 2 * i;
	int r = 2 * i + 1;

	int largest;
	if (l <= H && *(arr + l) > *(arr + i))
	{
		largest = l;
	}
	else
	{
		largest = i;
	}

	if (r <= H && *(arr + r) > *(arr + largest))
	{
		largest = r;
	}

	if (largest != i)
	{
		int t = *(arr + largest);
		*(arr + largest) = *(arr + i);
		*(arr + i) = t;
		maxHeapify(arr, largest);
	}
}

void buildMaxHeap(int *arr)
{
	for (int i = H / 2; i >= 1; i--)
	{
		maxHeapify(arr, i);
	}
}

int main(int argc, char *argv[])
{
	std::cin >> H;
	int A[MAX];

	for (int i = 1; i <= H; i++)
	{
		std::cin >> A[i];
	}
	buildMaxHeap(A);
	//maxHeapify(A, 1);

	for (int i = 1; i <= H; i++)
	{
	/*	if (i == 1)
		{
			std::cout << A[i];
		}
		else*/
		{
			std::cout << " " << A[i];
		}		
	}
	std::cout << std::endl;
	return 0;
}



Measured memory_bytes: 4944
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(int, N);

    const auto updiv = [](intmax_t n, intmax_t d) { return (n + d - 1) / d; };
    output(updiv(N, 2));

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    
    vector<bool> same(n);
    rep(i,n)if(p[i]==i+1)same[i]=true;
    
    int ans = 0;
    rep(i,same.size()){
        if(same[i]){
            same[i] = false;
            if(i+1<same.size())same[i+1] = false;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
    
    vector<P> p(n);  // p[i] : (おいしさ, ネタの種類)
    rep(i, n) {
        ll t, d;
        cin >> t >> d;
        p[i] = make_pair(d, t);
    }
    sort(rall(p));
    
    map<ll, ll> mp;
    priority_queue<ll, vector<ll>, greater<ll>> prQ;  // 小さい要素から順に取り出す
    ll sumD = 0;
    rep(i, k) {
        ll d = p[i].first;
        ll t = p[i].second;
        sumD += d;
        mp[t]++;
        if(mp[t] >= 2) {
            prQ.push(d);
        }
    }
    
    ll x = mp.size();
    ll ans = sumD + x*x;
    
    exrep(i, k, n-1) {
        if(prQ.empty()) {
            break;   
        }
        ll d = p[i].first;
        ll t = p[i].second;
        mp[t]++;
        if(mp[t] >= 2) {
            mp[t]--;
            continue;
        }
        sumD += d - prQ.top();
        prQ.pop();
        x++;
        chmax(ans, sumD + x*x);
    }
    
    out(ans);
    re0;
}


Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define f(i,a,n)        for(ll i=a;i<n;i++)
#define ve              vector
#define ss              second 
#define ff              first
#define pf              pop_front
#define pob             pop_back
#define psf             push_front
#define res(x)          cout<<x<<'\n'
#define read(t)         ll t;cin>>t

#define pii             pair<ll,ll>
#define vii             vector<ll,ll>
#define INFI            1000000000000000000;

int main(){
    int t;
    cin>>t;
    if(t>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <bits/stdc++.h>
#include <string.h>

using namespace std;

string s;

int main () {
    cin >> s;
    if ( s.size() >= 6 && s[2] == s[3] && s[4] == s[5] ) {
        cout << "Yes";
    }
    else {
        cout <<"No";
    }
}


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<ll> &v){
    for(ll x: v){
        cout<<x<<" ";
    }
    newline;
}

const ll MOD = 1e9+7;
const ll nax = 1e7+7;

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

    vector<ll> v(n);

    ll p = 0;

    for(ll i=0; i<n; i++){
        cin>>v[i];
        v[i]-=(i+1);
        p+=v[i];
    }

    sort(v.begin(), v.end());

    ll x = v[n/2];
    ll y = v[n/2-1];

    p/=n;
    ll a = p-1;
    ll b = p+1;

    ll a1=0, a2=0, a3=0,a4=0,a5=0;

    for(ll i=0; i<n; i++){
        a1+=abs(v[i]-a);
        a2+=abs(v[i]-p);
        a3+=abs(v[i]-b);
        a4+=abs(v[i]-x);
        a5+=abs(v[i]-y);
    }

    cout<<min({a1,a2,a3,a4,a5})<<endl;
    
    return 0;
}

Measured memory_bytes: 4776
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())
s = [((ord(ch) - 65 + n) % 26) + 65 for ch in input()]
print("".join(map(chr, s)))

Measured memory_bytes: 66980
#include <bits/stdc++.h>
using namespace std;
vector <bool> isprime (100005,true);
vector<int> prime;
vector<int> spf(100005);
void s(int n){
    isprime[0]=false;
    isprime[1]=false;
    for(int i=0;i<=n+1;i++){
        if(isprime[i]){
            prime.push_back(i);
            spf[i]=i;
        }
        for(int j=0;j<(int)prime.size() && i*prime[j]<=n+1 && prime[j]<=spf[i];j++){
            isprime[i*prime[j]]=false;
            spf[i*prime[j]]=prime[j];
        }
    }
}
int main(){
    int n;
    cin>>n;
    s(100004);
    if(isprime[n]==1){
        cout<<n;
    }
    else{
        int i=n+1;
        while(!isprime[i]){
            i++;
        }
        cout<<i;
    }
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,b,s[4],a=0;
    cin >> b;
    for(i=3;i>=0;i--){
        s[i]=b%10;
        b = b/10;
    }

    if(s[0]==0){
        if(s[1]<=9&&s[1]>0){
            a++;
        }
    }
    else if(s[0]==1){
        if(s[1]<=2&&s[1]>=0){
            a++;
        }
    }
    if(s[2]==0){
        if(s[3]<=9&&s[3]>0){
            a+=2;
        }
    }
    else if(s[2]==1){
        if(s[3]<=2&&s[3]>=0){
            a+=2;
        }
    }
    if(a==3){
        cout << "AMBIGUOUS";
    }
    else if(a==1){
        cout << "MMYY";
    }
    else if(a==2){
        cout <<"YYMM";
    }
    else{
        cout << "NA";
    }

}

Measured memory_bytes: 256
def main():
    people_num, emit_time = map(int, input().split())
    times = list(map(int, input().split()))
    answer = 0
    for i in range(1, people_num):
        if times[i] - times[i - 1] > emit_time:
            answer += emit_time
        else:
            answer += times[i] - times[i - 1]
    answer += emit_time
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 26704
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

bool used[8];
int N, num_big = 0;

void solve() {
    int ans_max = 0, ans_min = 0;
    REP(i, 8) if (used[i]) ans_min++;
    if (ans_min == 0 && num_big > 0) ans_min++;

    REP(i, 8) if (used[i]) ans_max++;
    ans_max += num_big;
    printf("%d %d\n", ans_min, ans_max);
}

int main() {
    cin >> N;
    int temp;
    REP(i, N) {
        cin >> temp;
        if (temp < 3200) used[temp / 400] = true;
        else num_big++;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> cnt(100100);
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll ans = 0;
    rep(i, 100100) ans += (ll)i * cnt[i];
    int q;
    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;
        ans += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4052
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    string a; cin >> a;
    if(a.find("7") != string::npos)
        cout << "Yes";
    else cout << "No";

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 3616
N=int(input())
hs=list(map(int, input().split()))

dp=[-100 for _ in range(N)]
dp[0]=0
dp[1]=abs(hs[1]-hs[0])+dp[0]


for i in range(2, N):
    tmp1 = abs(hs[i]-hs[i-1])+dp[i-1]
    tmp2 = abs(hs[i]-hs[i-2])+dp[i-2]
    dp[i] = min(tmp1, tmp2)
print(dp[-1])


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

int main(){
  int A,B,X;
  cin>>A>>B>>X;
  if((A<=X)&&(X<=(A+B))){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cnt=0

for i in range(n):
    a=list(map(int,input().split()))
    res=0
    for i,j in zip(a,b):
        res += i*j
    if res+c > 0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
n, c, k = map(int, raw_input().split())
arr = [input() for i in xrange(n)]
arr.sort()

res = 1
start = arr[0]
cur = c

for pas in arr:
	if c == 0:
		c = cur - 1
		start = pas
		res += 1
		continue

	if pas <= start + k:
		c -= 1
	else:
		res += 1
		c = cur -1
		start = pas

print res
		


Measured memory_bytes: 6336