akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[][] C = new int[N][2];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            sum += B[i];
            C[i][0] = A[i];
            C[i][1] = B[i];
        }
        sc.close();
        Arrays.sort(C, (a, b) -> Integer.compare(a[0], b[0]));
        long ans = 0;
        long tmp = M;
        for (int i = 0; i < M; i++) {
            if (C[i][1] < tmp) {
                tmp -= C[i][1];
                ans += (long)C[i][0] * (long)C[i][1];
            } else {
                ans += C[i][0] * tmp;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 94160
h, w = map(int, input().split())
a0 = '.' * w
r0 = [200] * w
for i in range(h):
  a = input()
  r = [i * 200]
  for x, y, z, u in zip(a0, '.' + a, a, r0):
    r.append(min(u + (x + z == '.#'), r[-1] + (y + z == '.#')))
  a0 = a
  r0 = r[1:]
print(r[-1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  rep(i,1,k+1){
    if(i%2==1){
      if(a%2==0){
        b+=a/2;
        a/=2;
      }
      else{
        a--;
        b+=a/2;
        a/=2;
      }
    }
    else{
      if(b%2==1){
        b--;
        a+=b/2;
        b/=2;
      }
      else{
        a+=b/2;
        b/=2;
      }
    }
  }
  co(a<<" "<<b);

  return 0;
}

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

int main()
{
  string S, T;
  cin >> S >> T;

  int count = S.length();
  
  for(int i = 0; i <= S.length() - T.length(); ++i)
  {
    int diff = 0;
    for(int j = 0; j < T.length(); ++j)
    {
      if(S[i+j] != T[j])
      {
        diff++;
      }
    }
    count = min(count, diff);
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3604
import numpy as np

H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
S = np.array(S)
S = (S == '.') * 1

R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(W):
    if i == 0:
        L[:, 0] = S[:, 0]
        R[:, W - 1] = S[:, W - 1]
    else:
        L[:, i] = L[:, i - 1] * S[:, i] + S[:, i]
        R[:, W - i - 1] = R[:, W - i] * S[:, W - i - 1] + S[:, W - i - 1]
for i in range(H):
    if i == 0:
        U[i] = S[i]
        D[H - 1] = S[H - 1]
    else:
        U[i] = U[i - 1] * S[i] + S[i]
        D[H - i - 1] = D[H - i] * S[H - i - 1] + S[H - i - 1]

print(np.max(R + L + U + D) - 3)

Measured memory_bytes: 251064
import sys


class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


N, C = map(int, input().split())
S = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]

R = [0] * (N + 1)
pos = 0
for i, (x, v) in enumerate(S):
    R[i + 1] = R[i] + v - (x - pos)
    pos = x
L = [0] * (N + 1)
pos = 0
for i, (x, v) in enumerate(reversed(S)):
    x = C - x
    L[i + 1] = L[i] + v - (x - pos)
    pos = x

RST = SegmentTree(R, max, 0)
LST = SegmentTree(L, max, 0)
ans1 = RST.get(0, N + 1)
ans2 = LST.get(0, N + 1)

score = 0
pos = 0
ans3 = 0
for i in range(N):
    x, v = S[i]
    score += v - (x - pos) * 2
    ans3 = max(ans3, score + LST.get(0, N - i))
    pos = x

score = 0
pos = 0
ans4 = 0
for i in range(N):
    x, v = S[N - 1 - i]
    x = C - x
    score += v - (x - pos) * 2
    ans4 = max(ans4, score + RST.get(0, N - i))
    pos = x


print(max([ans1, ans2, ans3, ans4]))


Measured memory_bytes: 85084
import heapq
def sol():
    n,m=map(int,input().split())
    a=[int(i) for i in input().split()]
    d={}
    w=[]
    q=[]
    for i in a:
        if i in d:
            d[i]+=1
        else:
            d[i]=1
            w.append(i)
    for i in w: heapq.heappush(q, i)
    for i in range(m):
        b,c=map(int,input().split())
        while b:
            if c>q[0]:
                x=min(b,d[q[0]])
                if c in d:
                    d[c]+=x
                    b-=x
                    d[q[0]]-=x
                    if d[q[0]]==0:
                        heapq.heappop(q)
                else:
                    d[c]=x
                    b-=x
                    d[q[0]]-=x
                    heapq.heappush(q,c)
                    if d[q[0]]==0:
                        heapq.heappop(q)
            else:
                break
    ans=chk=0
    for i in d:
        ans+=i*d[i]
    print(ans)

if __name__=="__main__":
    sol()

Measured memory_bytes: 101400
fun main() {
    val n = readLine()!!.toInt()
    val blue = HashMap<String, Int>()
    for (i in 0 until n) {
        val str= readLine()!!
        blue[str]?.let {
            blue[str] = it + 1
        }
        if (blue[str] == null) {
            blue[str] = 1
        }
    }

    val m = readLine()!!.toInt()
    val red = HashMap<String, Int>()
    for (i in 0 until m) {
        val str= readLine()!!
        red[str]?.let {
            red[str] = it + 1
        }
        if (red[str] == null) {
            red[str] = 1
        }
    }

    var max = 0
    for (x in blue) {
        val redValue = red[x.key] ?: 0
        val tmp = x.value - redValue
        if (max < tmp) {
            max = tmp
        }
    }

    print(max)
}

Measured memory_bytes: 35852
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

bool is_iroha(int n, set<int>& s) {
    if(n == 0) return true;
    else return s.count(n % 10) == 1 and is_iroha(n / 10, s);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    set<int> iroha_set;
    REP(i, 10) iroha_set.insert(i);
    REP(i, k) {
        int d;
        cin >> d;
        iroha_set.erase(d);
    }
    FOR(i, n, 99999)if(is_iroha(i, iroha_set)){
        cout << i << endl;
        return 0;
    }
    return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

H,W = inputIL()
a = inputILL(H)
b = inputILL(H)

ma = 80*160
    
dp = [[0 for __ in range(W)] for ___ in range(H)]

for i in range(H):
  for j in range(W):
    k = abs(a[i][j]-b[i][j])
    if i|j: 
      m = dp[i-1][j] | dp[i][j-1]
    else:
      m = 1<<ma
    dp[i][j] = (m<<k)|(m>>k)

k = 1<<ma
for i in range(m):
  if dp[-1][-1]&(k<<i) or  dp[-1][-1]&(k>>i):
    print(i)
    exit()

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	swap(X, Y);
	swap(X, Z);
	cout << X << " " << Y << " " << Z << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    vector<string> s(a);
    rep(i,a){
        cin >> s[i];
    }
    string s1;
    rep(i,b+2){
        s1 += "#";
    }
    cout << s1 << endl;
    for(auto ch: s){
        ch.insert(0,"#");
        ch.push_back('#');
        cout << ch << endl;
    }
    cout << s1 << endl;


    return 0;
}

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

int main () {
	int n; cin >> n;
	LL s = 0;
	for (int i = 1; i <= n; i ++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		s += 1LL * i;
	}
	cout << s << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;

const int MAXN = 2e5 + 7;
const ll INF = 2e9;

int move_x[4] = {-1, +1, 0, 0};
int move_y[4] = {0, 0, -1, +1};

bool vis[21][21];
char grid[21][21];

int n, m;

bool check(int dx, int dy) {
	if (dx >= 0 && dx < n && dy >= 0 && dy < m && !vis[dx][dy] && grid[dx][dy] == '.') return true;
	return false;
}

int bfs(int x1, int y1) {
	memset(vis, false, sizeof vis);
	queue<piii> q;
	q.push(piii(pii(x1, y1), 0));
	vis[x1][y1] = true;
	int best = 0;
	while(!q.empty()) {
		int currx = q.front().first.first;
		int curry = q.front().first.second;
		int dist = q.front().second;
		best = max(best, dist);
		q.pop();
		for (int i = 0; i < 4; i++) {
			int dx = currx + move_x[i], dy = curry + move_y[i];
			if (check(dx, dy)) {
				q.push(piii(pii(dx, dy), dist + 1));
				vis[dx][dy] = true;
			}
		}
	}
	return best;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (grid[i][j] == '#') continue;
			ans = max(ans, bfs(i, j));
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	string n;
	int ans=0;
	int len=0;
	
	cin >>n;
	for(int i=0;i<n.size();i++){
		if (n[i] == 'A' or n[i] == 'C' or n[i] == 'G' or n[i] == 'T'){
			
			len++;
		}else{
			
			chmax(ans,len);
			len=0;
		}
	}
	cout<<max(ans,len)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		long sum=1,t=0;
		for(int i=n-1;i>=1;i--){
			if(x[i]==x[i-1]){
				t++;
				sum*=x[i];
				i--;
			}
			if(t==2)
				break;
				
		}
		if(t<2)
			sum=0;
		System.out.print(sum);
	}
}

Measured memory_bytes: 50808
use proconio::*;

fn main() {
    input!{
        n: usize,
        d: i64,
        xy: [(i64, i64); n],
    }

    let mut ans = 0;
    for (x, y) in xy {
        if x*x + y*y <= d*d {
            ans += 1;
        }
    }

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


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

int main(){
  int s;
  cin >> s;
  int a = s / 100;
  int b = s % 100;
  
  if (1 <= a && a <= 12){
    
    if (1 <= b && b <= 12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "MMYY" << endl;
    }
  }
  else{
    if(1 <= b && b <= 12){
     cout << "YYMM" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
}
    
  


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define P pair<int,int>
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}

signed main(){
	sc(s)
	int n=s.size();
	if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[6]=='e'||s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[n-1]=='e'||s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[n-2]=='c'&&s[n-1]=='e'||s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[n-3]=='n'&&s[n-2]=='c'&&s[n-1]=='e'||s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[n-4]=='e'&&s[n-3]=='n'&&s[n-2]=='c'&&s[n-1]=='e'||s[0]=='k'&&s[1]=='e'&&s[n-5]=='y'&&s[n-4]=='e'&&s[n-3]=='n'&&s[n-2]=='c'&&s[n-1]=='e'||s[0]=='k'&&s[n-6]=='e'&&s[n-5]=='y'&&s[n-4]=='e'&&s[n-3]=='n'&&s[n-2]=='c'&&s[n-1]=='e'||s[n-7]=='k'&&s[n-6]=='e'&&s[n-5]=='y'&&s[n-4]=='e'&&s[n-3]=='n'&&s[n-2]=='c'&&s[n-1]=='e')c("YES")
	else c("NO")
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int n,m,x,a[200],k,l;
  k=0;
  l=0;
  cin >> n >> m >> x;
  rep(i,m)cin >> a[i];
  rep(i,m){if(a[i]>x)k++;
           else l++;
          }
  if(k>l)printf("%d",l);
  else printf("%d",k);
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

int main(){
	vector<pair<string,pair<int,int>>> v;
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		string S;
		int P;
		cin >> S >> P;
		v.PB({S,{-P,i+1}});
	}
	sort(v.begin(), v.end());
	for(int i=0; i<N; i++){
		cout << v[i].second.second << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N; cin >> N;
	string S; cin >> S;
	string res = "";

	long slen = S.length();
	for (int i = 0; i < slen; i++) res += char(((S[i] - 'A') + N) % 26 + 'A');

	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define endl "\n"
#define BRISK ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

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

    vi dp(n,0);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout<<dp[n-1];   
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int x;
    cin >> x;
    
    for(int i = 0; ; i++){
        int cnt = 0;
        int y = x + i;
        double b = sqrt(y);
        for(int j = 2; j <= b; j++)
        {
            if(y % j == 0)
            cnt++;

        }
        if(cnt == 0){
        cout << y << endl;
        return 0;
        }
    
    }
}

Measured memory_bytes: 256
program ABC042A
    implicit none
    integer(8)::i
    integer(8),dimension(3)::A
    read(5,*)(A(i),i=1,3)
    A=iqsort(A)
    if(A(1)==5.and.A(2)==5.and.A(3)==7)then
        print'(A)',"YES"
    else
        print'(A)',"NO"
    end if
contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC042A

Measured memory_bytes: 640
def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(M):
        a, b = map(int, input().split())
        AB.append([a, b])

    F = [0] * N
    S = [0] * N
    
    for a, b in AB:
        if a == 1:
            F[b] = True
        if b == N:
            S[a] = True

    # print(F)
    # print(S)

    ans = 'IMPOSSIBLE'
    for i in range(N):
        if F[i] and S[i]:
            ans = 'POSSIBLE'
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 39244
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<string>
using namespace std;
#define gc getchar()
#define fup(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define hh putchar(10)
#define ll long long
struct zg{template<class T>inline zg&operator >>(T &x){T f=1;char a;while((a=gc)<48)
if(a==45)f=-1;for(x=a^48; (a=gc)>47; x=(x<<3)+(x<<1)+(a^48));x*=f;}}qin;void Main();
struct nnn{int x1,x2,x3;};int main(){Main();return 0;}

void Main()
{
    map<string,int,greater<string> >mp;
    string a;
    int n;
    qin>>n;
    while(n--){
        cin>>a;
        ++mp[a];
    }
    map<string,int>::iterator it=mp.begin();
    int s=-1;
    for(;it!=mp.end();++it)
    {
        s=max(s,(*it).second);
    }
    for(it=mp.end();it!=mp.begin();--it)
    {
        if(it==mp.end())continue;
        if((*it).second==s)cout<<it->first<<'\n';
    }
    if((mp.begin())->second==s)cout<<(mp.begin())->first<<'\n';
}





Measured memory_bytes: 25216
import java.util.Scanner;

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

    int o;
    if(n%2==0) o = n/2;
    else       o = n/2+1;
    double nn = (int)n;
    double oo = (int)o;
    System.out.println(oo/nn);
  }

}

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

dou memo[3002][3002];
dou p[3002];
ll n;

dou fil(ll i,ll cnt)
{
    if(memo[i][cnt]!=-1.0)return memo[i][cnt];
    if(i==n)return 100000000.0;

    dou ans=0;
    if(n-i-cnt>0)
    {
        ans+= ( (p[i]*100.0)*fil(i+1,cnt) );
    }
    if(cnt>0)ans+=( (100-p[i]*100)*fil(i+1,cnt-1) );
    ans/=10000000000.0;
    ans*=100000000.0;

    return memo[i][cnt]=ans;
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)cin>>p[i];

    for(ll i=0;i<3002;i++)
    {
        for(ll j=0;j<3002;j++)memo[i][j]=-1.0;
    }
    ll cnt=n/2;

    double ans=0.0;
    for(ll i=0;i<=cnt;i++)
    {
        ans+=fil(0,i);
    }
    cout<<fixed<<setprecision(10)<<ans/100000000.0<<endl;
}


Measured memory_bytes: 70784
package main

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

func insertionSort(n int, as []int, g int, count *int) {
	for i := 0; i < n-g; i++ {
		for j := i + g; j > g-1; j = j - g {
			if as[j] < as[j-g] {
				a := as[j]
				as[j] = as[j-g]
				as[j-g] = a
				*count = *count + 1
			} else {
				j = g - 1
			}
		}
	}
}

func shellSort(n int, as []int) {
	count := 0
	var gs []int
	for i := 0.0; i < 100 && n/int(math.Pow(2, i)) >= 1; i++ {
		gs = append(gs, n/int(math.Pow(2, i)))
	}
	m := len(gs)

	for _, g := range gs {
		insertionSort(n, as, g, &count)
	}

	fmt.Println(m)
	printArray(gs)
	fmt.Println(count)
	for _, v := range as {
		fmt.Println(v)
	}
}

func printArray(as []int) {
	fmt.Println(strings.Trim(fmt.Sprint(as), "[]"))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	var as []int
	for i := 0; i < n; i++ {
		a := nextInt(sc)
		as = append(as, a)
	}
	shellSort(n, as)
}



Measured memory_bytes: 24516
import math  
n = int(input())

A_list = [int(input()) for i in range(n)]
sort_A = sorted(A_list)
mA =  sort_A[-1]
second = sort_A[-2]
for i in A_list :
  if i == mA :
    print(second)
  else :
    print(mA)
  

Measured memory_bytes: 14112
#include <iostream>
#include<iomanip>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

static long long gcd(long long a,long long b){
	int amari = a % b;
	int c = b;
	if(amari == 0){
		return b;
	}else{
		return gcd(b,amari);
	}
}
static long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

int main() {
    int a,b,n;
    cin >> n >> a >> b;
    if(n * a >= b){
        cout << b;
    }else{
        cout << a*n;
    }

}



Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int number;
        number =input.nextInt();
        int sum=0;
        int max=0,temp;
        String s=input.next();
        for(int i=0;i<number;i++)
        {
            if(s.charAt(i)=='I')
            {
                sum++;
                if(max<sum)
                {
                    max=sum;
                }
            }
            else {
                sum--;
                if (max<sum)
                    max=sum;
            }
        }
        System.out.println(max);
    }
    
}


Measured memory_bytes: 27076
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s,t;std::cin>>s>>t;
    std::sort(s.begin(),s.end());
    std::sort(t.begin(),t.end(),std::greater<>{});
    std::cout<<(s<t?"Yes":"No")<<std::endl;
}

Measured memory_bytes: 256
a = [[int(input()), 0]for i in range(5)]
for i in range(5):
    if a[i][0] % 10 == 0:
        a[i][1] = 9
    else:
        a[i][1] = a[i][0] % 10
a = sorted(a, key=lambda x: x[1], reverse=True)
b = 0
for i in range(5):
    if i == 4:
        b += a[i][0]
    else:
        b += (a[i][0] + 9) // 10 * 10
print(b)


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

const int MOD = 1e9+7;

int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  int j;
  ll ans=1;
  bool tate;
  if(s[0]==t[0]){
    j=1; ans*=3; tate=1;
  }else{
    j=2; ans*=6; tate=0;
  }
  for(int i=j; i<n; i++){
    if(s[i]==t[i]){
      if(tate){
        ans*=2; ans%=MOD;
      }else{
        ans*=1; ans%=MOD;
      }
      tate=1;
    }else{
      if(tate){
        ans*=2; ans%=MOD;
      }else{
        ans*=3; ans%=MOD;
      }
      i++; tate=0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int ans=0;
    rep0(r,N+1)rep0(b,N+1){
        int M=N-R*r-B*b;
        if(M>=0&&M%G==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)


template<class T,class U>
T pw(T n,U m){
    if(m==0) return 1;
    else if(m%2==0) return pw(n*n,m/2);
    else return n*pw(n,m-1);
}
struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}
modint fc[200010]={1};
modint fct(int n){
    if(fc[n].a) return fc[n];
    return fc[n]=modint(n)*fct(n-1);
}
modint ifc[200010]={1};
modint ifct(int n){
    if(fc[n].a) return ifc[n];
    return ifc[n]=modint(n).inv()*ifct(n-1);
}
void initfct(int n){
    ifct(n);
    ifr(i,n) ifc[i]=ifc[i+1]*(i+1);
}
modint cmb(int n,int r){
    if(n<0||r<0||n<r) return 0;
    return fct(n)*ifct(r)*ifct(n-r);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,A,B,C;
    cin>>n>>A>>B>>C;
    modint r=modint(A+B).inv(),k=r*100;
    modint a=r*A,b=r*B;
    modint kari=pw(a,n)*n;
    modint ans(0);
    Fr(i,n){
        ans+=kari;
        //cout<<kari<<endl;
        kari*=b*(n+i)*(n+i-1)*modint(i*(n+i-1)).inv();
    }
    kari=pw(b,n)*n;
    Fr(i,n){
        ans+=kari;
        //cout<<kari<<endl;
        kari*=a*(n+i)*(n+i-1)*modint(i*(n+i-1)).inv();
    }
    cout<<ans*k<<endl;
}

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

int main(){
	
	int a,b,sup;
	
	while(cin >> a >> b){
		
		a += b;
		sup = 0;  
		
		while(a>0){
			sup++;
			a/=10;
		}
		
		cout << sup << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for ( int i =0; i < n ; i ++)
int N ,C , X ;
int D [30][39];
int t [3][30];
int main ()
{
	scanf("%d %d",&N,&C);
	rep (i,C) rep (j,C) scanf("%d",&D[i][j]);
	rep (i,N) rep (j,N) scanf("%d",&X ) , t[(i+j)%3][X-1]++;
	int res =1 <<30;
	rep (i,C) rep (j,C) if ( i != j ) rep (k,C) if ( i != k && j != k )
	{
int tt =0;
rep (l , C ) tt += D [ l ][ i ]* t [0][ l ];
rep (l , C ) tt += D [ l ][ j ]* t [1][ l ];
rep (l , C ) tt += D [ l ][ k ]* t [2][ l ];
if ( tt < res ) res = tt ;}
printf ("%d\n ",res );
}


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

using namespace std;


void solve() {
    string S; cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
struct edge{ll from, to, cost;};

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;
}

int V,E;
vector<edge> es(2000);
vector<ll> d(1000,IINF);
vector<bool> used(1000,false);

bool BellmanFord(int s){
    d[s]=0;
    int count=0;
    while (true){
        bool update=true;
        rep(i,E){
            edge e=es[i];
            if (d[e.from]!=IINF&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=false;
                if (count==V-1&&used[e.to]){
                    return true;
                }
            }
        }
        if (update){
            return false;
        }
        count++;
        if (count==V){
            return false;
        }
    }
}

vector<vector<int>> G(1000);
void reachgoal(int g){
    used[g]=true;
    queue<int> que;
    que.push(g);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for (auto nv:G[v]){
            if (used[nv]){
                continue;
            }
            used[nv]=true;
            que.push(nv);
        }
    }
}

int main(){
    cin >> V >> E;
    rep(i,E){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--,b--;
        es[i]=edge{a,b,-c};
        G[b].push_back(a);
    }
    reachgoal(V-1);
    if (BellmanFord(0)){
        cout << "inf" << endl;
        return 0;
    }
    cout << -d[V-1] << endl;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
kakeru = [list(map(int,input().split())) for _ in range(n)]
kakerareru = [int(input()) for _ in range(m)]
for a in range(n):
    kotae = 0
    for b in range(m):
        kotae += kakeru[a][b]*kakerareru[b]
    print(kotae)

Measured memory_bytes: 8004
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc069_a.cpp
 * time   : Tue Apr 28 23:22:23 2020
 * quest  : A - K-City
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, n;
  cin >> m >> n;
  cout << (m - 1) * (n - 1) << "\n";
  return 0;
}


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

int minBigger(int i,string& N,string& ans,set<char>& avlb){
	while (i >= 0){
		for (auto& el : avlb){
			if (el > N[i]){
				ans[i] = el;
				return i;
			}
		}
		i--;
	}
}
int main()
{
	set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
	int K;
	string N;
	cin >> N >> K;
	for (int i = 0; i < K; ++i){
		char t;
		cin >> t;
		avlb.erase(t);
	}
	int len = N.length();
	N = '0' + N;
	string ans;
	ans.resize(len + 1);
	for (int i = 1; i <= len; ++i){
		if (avlb.find(N[i]) == avlb.end()){
			i = minBigger(i, N, ans, avlb);
			int j = i + 1;
			while (j <= len){
				ans[j] = *avlb.begin();
				j++;
			}
			break;
		}
		else{
			ans[i] = N[i];
		}
	}
	if (ans[0] == '\0'){ 
		ans=ans.substr(1, len + 1); 
	}
	int ansint = stoi(ans);
	cout << ansint << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define REP(i,x,y) for(ll i = x;i <= y;++i)
#define debug(x) cerr<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
ll power(ll x,ll y,ll z) {
	ll ret = 1;
	while(y > 0) {
		if(y & 1) ret = (ret*x)%z;
		x = (x*x)%z;
		y >>= 1;
	}
	return ret;
}
int main() {
	
	ll n, p;	
	cin >> n >> p;
	string s;
	cin >> s;
	vector<ll>mod(p,0);
	mod[0] = 1;
	ll val = 0, ans = 0, po = 1;
	for(ll i = n;i >= 1;--i) {
		val = (val + (s[i - 1] - '0') * po) % p;
		ans += mod[val];
		po = (po * 10) % p;
		// debug3(i,val,mod[val]);
		mod[val]++;
	}
	if(p == 2 || p == 5) {
		ans = 0;
		REP(i,1,n) {
			if((s[i - 1] - '0') % p == 0) ans += i;
		}
	}
	cout << ans << "\n";

	return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b;
    rep(i, n){
        cin >> a[i];
        if ((i % 2 == 0 && n % 2 == 0) || (i % 2 == 1 && n % 2 == 1) ){
            b.push_back(a[i]);
        }else{
            b.insert(b.begin(), a[i]);
        }
    }
    rep(i, n-1){
        cout << b[i] << " ";
    }
    cout << b[n-1] << endl;


    return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>
#define N 100
int main(){
  int M[N][N];
  int n, u, k, v;
  int i, j;

  scanf("%d", &n);

  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ){
      M[i][j] = 0;
    }
  }

  for( i = 0; i < n; i++ ){
    scanf("%d", &u);
    scanf("%d", &k);
    u--;
    for( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ){
      if( j != 0 ){
	printf(" ");
      }
      printf("%d", M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    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 resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    x=int(input())
    if x==0:
      print(1)
    else:
      print(0
      )

if __name__ == '__main__':
    resolve()

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

int main() {
  ll N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    ll x;
    cin >> x;
    N -= x;
  }
  if (N >= 0) cout << N << endl;
  else cout << -1 << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



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

typedef pair<string,int> P;

int main(){
  string str;
  int page,cnt=0;
  vector<P> v;

  while(cin >> str >> page){
    v.push_back(P(str,page));
    cnt++;
  }

  sort(v.begin(),v.end());
  for(int i = 0 ; i < cnt; i++){
    if(i==0){
      cout << v[i].first << endl;
      cout << v[i].second;
      continue;
    }

    if(v[i].first == v[i-1].first && v[i].second!=v[i-1].second){
      cout << ' ' << v[i].second;
      continue;
    }
    else cout << endl;

    cout << v[i].first << endl;
    cout << v[i].second;
    }

  puts("");

  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *p = ALLOC (n, i32);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, p + i);
  }
  i32 ans = 0;
  for (i32 i = 1; i < n - 1; ++i) {
    if (p[i] < MAX(p[i - 1], p[i + 1]) && p[i] > MIN(p[i - 1], p[i + 1])) {
      ans++;
    }
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}

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

int main() {
  string N;

  bool first = true;
  while (cin >> N) {
    if (!first) cout << ' ';
    for (int i = 0; i < N.size(); i++) {
      if (islower(N.at(i)))
        cout << (char)toupper(N.at(i));
      else if (isupper(N.at(i)))
        cout << (char)tolower(N.at(i));
      else
        cout << N.at(i);
    }
    first = false;
  }

  cout << endl;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL N;
    cin >> N;
    vector<LL>  a(N+1);
    LL M = -1000001;
    LL m = 1000001;
    LL Mid = 0;
    LL mid = 0;
    for(int i = 1;i <= N;i++){
        cin >> a[i];
        if(M < a[i]){
            M = a[i];
            Mid = i;
        }
        if(m > a[i]){
            m = a[i];
            mid = i;
        }
    }
    cout << 2*N << endl;
    if(m > 0 || abs(M) >= abs(m)){
        a[1] += M*2;
        cout << Mid << " " << 1 << endl;
        cout << Mid << " " << 1 << endl;
        for(int i = 2;i <= N;i++){
            a[i] += a[1]+a[i-1];
            cout << 1 << " " << i << endl;
            cout << i-1 << " " << i << endl;
        }
    }else{
        a[N] += m*2;
        cout << mid << " " << N << endl;
        cout << mid << " " << N << endl;
        for(int i = N-1;i >= 1;i--){
            a[i] += a[N]+a[i+1];
            cout << N << " " << i << endl;
            cout << i+1 << " " << i << endl;
        }
    }
}

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

using namespace std;
using ll = long long;

int main()
{
    int n; cin >> n;
    vector<ll> dp(n + 1);
    dp[0] = 1, dp[1] = 1;

    for(int i = 2; i <= n; i++){
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3112
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N):
    B.append(int(input()))

a=str('Yes')
b=str('No')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int cnt = 0;

    rep(i, n) {
        if (a[a[i] - 1] == i + 1) cnt++;
    }

    cout << cnt / 2 << endl;

    return 0;
}



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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    int white = 0;
      for (int j = 0; j < W; j++){
      if(data.at(i).at(j) == '.') {white++;}}
    
    if(white == W)    
    {
      for(int j = 0; j < W; j++) {
        data.at(i).at(j) = 'k';}
    }
  

  }
  
   
  
  for (int j = 0; j < W; j++) {
    int white = 0;
      for (int i = 0; i < H; i++){
      if(data.at(i).at(j) != '#') {white++;}}
    
    if(white == H)    
    {
      for(int i = 0; i < H; i++) {
        data.at(i).at(j) = 'k';}
    }
  

  }
  
  
  for (int i = 0; i < H; i++) {
    int white = 0;
    for (int j = 0; j < W; j++) {  
      if(data.at(i).at(j) != 'k') {
      cout << data.at(i).at(j);} else {white++;}
    }
    if(white != W){cout << endl;}
  }
}
  

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;



int main(){
  int X,N;
  cin >> N >> X;
  long ans = 1;
  long len = 0;
  for(int t=0; t<N; t++)
  {
    long tmp;
    cin >> tmp;
    len += tmp;
    if(len > X)
    {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256