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

using namespace std;

int main() {
    int ans = 0;
    string s;
    while (getline(cin, s)) {
        int sz = s.size(), l, r;
        for (int i = 0; i < sz; i++) {
            if (!isdigit(s[i])) continue;
            l = i;
            while (isdigit(s[++i]));
            r = i;
            ans += atoi(s.substr(l, r - l).c_str());
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2968
import sys

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, node):
        def helper(root):
            y, x = None, root
            while isinstance(x, TreeNode):
                y = x
                if node.val < x.val:
                    x = x.left
                else:
                    x = x.right
            if y is None:
                root = node
            elif node.val < y.val:
                y.left = node
            else:
                y.right = node
            return root
            
        self.root = helper(self.root)

    def find(self, val):
        def helper(root):
            if root is None:
                return None
            elif root.val == val:
                return root
            elif val < root.val:
                return helper(root.left)
            else:
                return helper(root.right)
        return helper(self.root)

    
    def inorder(self):
        def helper(root):
            return [] if root is None else helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)

    def preorder(self):
        def helper(root):
            return [] if root is None else [root.val] + helper(root.left) + helper(root.right)
        return helper(self.root)

if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for _ in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' ' + ' '.join(map(lambda x: str(x), bst.inorder()))
            print ' ' + ' '.join(map(lambda x: str(x), bst.preorder()))
        elif tmp.startswith('insert'):
            _, val = tmp.split()
            node = TreeNode(int(val))
            bst.insert(node)
        elif tmp.startswith('find'):
            _, val = tmp.split()
            print ('yes' if bst.find(int(val)) is not None else 'no')

Measured memory_bytes: 200140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n, num[5010];

int mina(int a, int b) {
	if (a < b) return a;
	return b;
}

int main() {
	cin >> n;
	while (n != 0) {
		int sum = 0;
		int maxsum = 0;
		int minmax = -100001;
		for (int i = 0; i < n; i++) {
			cin >> num[i];
			sum += num[i];
			if (sum < 0) sum = 0;
			if (num[i] >= 0) minmax = 100000*5000+1;
			if (num[i] < 0 && num[i] > minmax) minmax = num[i];
			if (sum > maxsum) maxsum = sum;
		}
		cout << mina(maxsum, minmax) << endl;

		cin >> n;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int a[5],ans=10000;
    for(int i=0;i<5;i++)cin>>a[i];
    sort(a,a+5);
    do{
        int num=0;
        for(int i=0;i<5;i++){
            num+=a[i];
            if(i!=4){
                int x=a[i]%10;
                num+=(10-x)%10;
            }
        }
        ans=min(ans,num);
    }while(next_permutation(a,a+5));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
N, A, B = gets.chomp.split.map(&:to_i)

def digit_sum(n)
  sum = 0
  while (n > 0) do
    sum += n % 10
    n /= 10
  end
  sum
end

result = []
(1..N).each_with_index do |n, i|
  s = digit_sum(n)
  result << i + 1 if A <= s && s <= B
end
puts result.sum

Measured memory_bytes: 14436
#include <stdio.h>
#include <algorithm>
int n;
long long l[100];
int x;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", l + i);
	}
	std::sort(l, l + n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k])x++;
			}
		}
	}
	printf("%d\n", x);
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 100005;
int L[N], R[N];
void rem(multiset<int> & ms, int x){
	ms.erase(ms.find(x));
}
int get(multiset<int> & A, multiset<int> & B){
	if(A.empty() || B.empty()) return -2e9 - 10;
	return max(0, *B.begin() - *A.rbegin() + 1);
}

int perm[N];
int main(){
	int n; sd(n);
	int mxL = 0, which = 0;
	multiset<int> l, r;
	for(int i = 1; i <= n; i++){
		sd(L[i]); sd(R[i]);
		l.insert(L[i]);
		r.insert(R[i]);
		if(L[i] > mxL){
			mxL = L[i];
			which = i;
		}
		perm[i] = i;
	}
	sort(perm + 1, perm + n + 1, [](int i, int j){return R[i] > R[j];});
	int ans = 0;
	// all but one
	for(int i = 1; i <= n; i++){
		rem(l, L[i]);
		rem(r, R[i]);
		int maxl = *l.rbegin(), minr = *r.begin();
		// if(i == 1 && L[1]==1) trace(maxl, minr);
		ans = max(ans, R[i] - L[i] + 1 + max(0, minr - maxl + 1));
		l.insert(L[i]);
		r.insert(R[i]);
	}
	l.clear(); r.clear();
	for(int i = 1; i <= n; i++){
		if(i != which){
			l.insert(L[i]); r.insert(R[i]);
		}
	}
	multiset<int> l1, r1;
	l1.insert(L[which]);
	r1.insert(R[which]);
	for(int i = 1; i <= n; i++){
		int ind = perm[i];
		ans = max(ans, get(l, r) + get(l1, r1));

		if(ind != which){
			l1.insert(L[ind]);
			r1.insert(R[ind]);
			rem(l, L[ind]);
			rem(r, R[ind]);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 12800
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
ans = 0

n.times do |i|
    li = i + a[i]
    h[li] += 1
end

n.times do |i|
    ri = i - a[i]
    ans += h[ri] if h.has_key?(ri)
end

puts ans

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

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        String s = in.next();
        for (int i = 0; i < s.length() - 8; i++) {
            out.print(s.charAt(i));
        }
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 23380
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)
	results := strings.Split(str, "")
	winCount := 0
	for _, result := range results {
		if result == "o" {
			winCount++
		}
	}

	if winCount + 15 - len(results) >= 8 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	char input[256];
	scanf("%255s", input);
	char onec = 0;
	char twoc = 0;
	int onen = 0;
	int twon = 0;

	for( int i=0; i < 4; i++ ) {
		if( input[i]==onec ) {
			onen++;
		} else if( input[i]==twoc ) {
			twon++;
		} else if( onec == 0 ) {
			onec = input[i];
			onen++;
		} else if( twoc == 0 ) {
			twoc = input[i];
			twon++;
		}
	}

	if( onen==2 && twon==2 ) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;

}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
    n=int(input())
    XY=[[] for _ in range(n)]
    for i in range(n):
        a=int(input())
        for j in range(a):
            x,y=map(int,input().split())
            XY[i].append((x-1,y))
    tf=list(product([1,0],repeat=n)) #i人目の正直か嘘か
    ans=0
    for tfx in tf:
        for i,x in enumerate(tfx):
            if x==1: #i番目が正直人なら
                for xxy in XY[i]:#i番目の証言を
                    if tfx[xxy[0]]!=xxy[1]:
                        break
                else:
                    continue
                break
        else:
            ans=max(ans,sum(1 if a==1 else 0 for a in tfx))
    print(ans)


        
if __name__=='__main__':
    main()

Measured memory_bytes: 49244
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        List<Integer> list = new ArrayList<>();

        if(str.length() == 1) {
            System.out.println(0);
        } else {
            for(int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                list.add(Character.getNumericValue(c));
            }
            int minCount = list.size();
            for(int i = 0; i < 2; i++) {
                int count = 0;
                for(int j = 0; j < list.size(); j++) {
                    if(j % 2 == 0 && list.get(j) != i) count++;
                    if(j % 2 == 1 && list.get(j) == i) count++;
                }
                if(minCount >= count) minCount = count;
            }

            System.out.println(minCount);
        }

    }
}

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

// const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

// 二項係数nCr
const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
  if ((2 * X - Y) % 3 == 0 && (2 * Y - X) % 3 == 0)
  {
    COMinit();
    int x = (2 * X - Y) / 3;
    int y = (2 * Y - X) / 3;
    ans = COM(x + y, x);
    cout << ans << endl;
  }
  else
    cout << 0 << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n, a, b,c;
string s;

int main(){
    cin >> a >> b >> c;
    int ma = max(a,b);
    ma = max(ma, c);
    int des[3];
    des[0] = ma-a;
    des[1] = ma-b;
    des[2] = ma-c;
    sort(des, des+3);
    int kig = 0;
    kig += des[1]%2;
    kig += des[2] % 2;
    int ans;
    if(kig == 2){
        ans++;
        ans += (des[1]-1)/2;
        ans += (des[2]-1)/2;
    }
    else if(kig == 1){
        if(des[1] % 2 == 0){
            ans += des[1]/2;
        }
        else{
            ans += des[1]/2+1;
        }

        if(des[2]%2 == 0)   ans += des[2] /2;
        else    ans += des[2]/2+1;
        ans++;
    }
    else{
        ans += des[2]/2;
        ans += des[1]/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, t, x, y;
	int flag;
	int i;

	scanf("%d", &n);

	flag = 0;
	i = 0;
	while (i < n)
	{
		scanf("%d %d %d", &t, &x, &y);
		if ((x + y + t) % 2 != 0 || t < x + y)
		{
			flag = 1;
		}
		i++;
	}

	if (flag)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}

	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
aa=list(map(int,input().split()))
tonari=[[] for i in range(n)]
for x in range(m):
  a,b=map(int,input().split())
  tonari[a-1].append(b-1)
  tonari[b-1].append(a-1)
  
auto=[0]*n



for y in range(n):
  if auto[y]>0:
    continue
  elif len(tonari[y])==0:
    continue
  for z in range(len(tonari[y])):
    v=tonari[y][z]
    if aa[y]>aa[v]:
      auto[v]+=1
    elif aa[y] == aa[v]:
      auto[y]+=1
      break
    elif aa[y] < aa[v]:
      auto[y]+=1
      break
  

print(auto.count(0))



Measured memory_bytes: 30152
#include <stdio.h>
#include <set>
using namespace std;
const int N=1e6+10;
int main(){
    int n,m,a[N];
    set<int> s;
    scanf("%d%d",&n,&m);
    if(n<m)m=n;
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<m;i++){
        if(s.find(a[n-1-i])!=s.end()){
            if(m<n)m++;
            continue;
        }
        printf("%d\n",a[n-1-i]);
        s.insert(a[n-1-i]);
    }
    
}


Measured memory_bytes: 5568
import sys

n, x, *lst = map(int, sys.stdin.read().split())
res = 0
lst.append(0)
for i in range(n, 0, -1):
  tmpsum = lst[i] + lst[i - 1]
  if tmpsum > x:
    res += tmpsum - x
    lst[i - 1] -= tmpsum - x

print(res)


Measured memory_bytes: 14092
#include <cstdio>

using namespace std;

int a[8][8];
char s[8][9];

int main() {
    int h, w, x = 0, y = 0, i, j;
    
    scanf("%d %d", &h, &w);
    
    for (i = 0; i < h; i++) scanf("%s", s[i]);
    
    if (s[0][0] != '#' || s[h - 1][w - 1] != '#') {
        puts("Impossible");
        
        return 0;
    }
    
    while (1) {
        a[x][y] = 1;
        
        if (x == h - 1 && y == w - 1) break;
        
        if (x == h - 1) {
            if (s[x][y + 1] != '#') {
                puts("Impossible");
                
                return 0;
            }
            
            y++;
        } else if (y == w - 1) {
            if (s[x + 1][y] != '#') {
                puts("Impossible");
                
                return 0;
            }
            
            x++;
        } else {
            if ((s[x][y + 1] == '#' && s[x + 1][y] == '#') || (s[x][y + 1] != '#' && s[x + 1][y] != '#')) {
                puts("Impossible");
                
                return 0;
            }
            
            if (s[x][y + 1] == '#') {
                y++;
            } else {
                x++;
            }
        }
    }
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '#' && a[i][j] == 0) {
                puts("Impossible");
                
                return 0;
            }
        }
    }
    
    puts("Possible");
    
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();

            var A = cin.Read();
            var B = cin.Read();
            var C = cin.Read();

            if (A[A.Length - 1] == B[0] && B[B.Length - 1] == C[0])
                WriteLine("YES");
            else
                WriteLine("NO");
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 11220
from collections import*
(n,m),*c=[[*map(int,i.split())]for i in open(0)]
g=[[]for _ in range(n+1)]
for a,b in c:
    g[a]+=[b]
    g[b]+=[a]
q=deque([1])
r=[0]*(n+1)
while q:
    v=q.popleft()
    for i in g[v]:
        if r[i]==0:
            r[i]=v
            q.append(i)
print("Yes",*r[2:],sep="\n")

Measured memory_bytes: 60284
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int N, X; cin >> N >> X;
	int m[100] = {};
	int minV = 1 << 10;
	int count = 0;

	rep(i, 0, N) {
		cin >> m[i];
		X -= m[i];
		count++;
		minV = min(minV, m[i]);
	}
	count += X / minV;
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

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

long long bipow(long long n, int m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<pair<long long, long long>> AB(N);
    REP(i, N){
        long long A, B;
        cin >> A >> B;
        if(A==0 && B==0) AB[i] = make_pair(0, 0);
        else if(A==0) AB[i] = make_pair(0, 1);
        else if(B==0) AB[i] = make_pair(1, 0);
        else{
            long long g = gcd(A, B);
            A /= g;
            B /= g;
            if(A < 0){
                A = -A;
                B = -B;
            }
            AB[i] = make_pair(A, B);
        }
    }
    map<pair<long long, long long>, long long> mp;

    REP(i, N) mp[AB[i]]++;
    for(auto x : mp){
        long long a = x.first.first;
        long long b = x.first.second;
        long long aa = b;
        long long bb = -a;
        if(aa < 0){
            aa = -aa;
            bb = -bb;
        }
        if(mp.find(make_pair(aa, bb)) == mp.end()){
            mp[make_pair(aa, bb)] = 0;
        }
    }
    //for(auto x : mp)
    //    cerr << x.first << " " << x.second << endl;

    long long zero = mp[make_pair(0, 0)];
    long long one0 = mp[make_pair(0, 1)];
    long long one1 = mp[make_pair(1, 0)];
    vector<pair<long long, long long>> v;
    v.emplace_back(one0, one1);

    for(auto x : mp){
        long long a = x.first.first;
        long long b = x.first.second;
        if(a==0 || b==0) continue;
        if(b < 0) continue;
        long long cnt = x.second;
        long long cnt2 = mp[make_pair(b, -a)];
        v.push_back(make_pair(cnt, cnt2));
    }
    long long ans = 1;
    for(auto x : v){
        long long a = x.first;
        long long b = x.second;
        //cerr << a << " " << b << endl;
        ans *= ((bipow(2, a)+bipow(2, b))%MOD + (MOD - 1)) % MOD;
        ans %= MOD;
    }
    ans = (ans + MOD - 1) % MOD;
    ans = (ans + zero) % MOD;
    cout << ans << endl;

    return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n, a, b;
    cin >> n;
    cin >> a;
    cin >> b;

    cout << min(n * a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 int S, h, m;
 scanf("%d",&S);
 h = S / (60*60);
 S -= h * 60 * 60;
 m = S / 60;
 S -= m * 60;
 printf("%d:%d:%d\n", h, m, S);
 return 0;
}

Measured memory_bytes: 592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k < a+1) {
        cout << k << endl;
    }
    else if(k < a+b+1){
        cout << a << endl;
    }
    else {
        cout << a - (k - (a+b)) << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)



int main(){
	int N;
	cin>>N;
	vector<long long> A(N);
	long long mini = 1000000001;
	long long ans = 0;
	int cnt = 0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		mini = min(mini,abs(A[i]));
		ans+=abs(A[i]);
		if(A[i]<0)cnt++;
	}
	
	if(cnt%2==0)cout<<ans<<endl;
	else{
		ans-=mini*2;
		cout<<ans<<endl;
	}
	
	return 0;
}


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

bool f(char c) {
  return c == 'R';
}

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

  int ans = 0;
  if (f(S[0]) && f(S[1]) && f(S[2]))
    ans = 3;
  else if (f(S[0]) && f(S[1]) || f(S[1]) && f(S[2]))
    ans = 2;
  else if (f(S[0]) || f(S[1]) || f(S[2]))
    ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include "boost/multiprecision/cpp_int.hpp"

using namespace std;
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

	cin.tie(nullptr); ios::sync_with_stdio(false);

	int x, a, b; cin >> x >> a >> b;

	if (abs(x - a) > abs(x - b))cout << "B";
	else cout << "A";


	return 0;

}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m,a,b,c,d;
      cin>>a>>b>>c>>d;
      ans=b*d;
      ans=max(ans,a*d);
      ans=max(ans,b*c);
      ans=max(ans,a*c);
      cout<<ans;
      
	return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 1000100;
int n;
vector<string> t;
const int ALFA = 'z' - 'a' + 1;
int res = 0;
vector<int> ile(ALFA);
void licz(vector<int>& p,int kt){
  debug(p,kt);
  vector<int> TODO;
  R(i,SZ(p)){
    if(SZ(t[p[i]]) == kt + 1){
      int ost = t[p[i]][kt];
      res += ile[ost];
      ile[ost]++;
      TODO.PB(ost);
      p[i] = p.back();
      p.pop_back();
      i--;
    }
  }
  R(i,ALFA){
    vector<int> pom;
    for(int j:p){
      if(t[j][kt] == i){
        pom.PB(j);
      }
    }
    if(SZ(pom)){
      int ak = ile[i];
      ile[i] = 0;
      res += ak * SZ(pom);
      licz(pom, kt+1);
      ile[i] = ak;
    }
  }
  R(i,SZ(TODO)){
    ile[TODO[i]]--;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  t.resize(n);
  R(i,n){
    cin >> t[i];
    reverse(ALL(t[i]));
    for(char &el:t[i]){
      el -= 'a';
    }
  }
  vector<int> p(n);
  R(i,n)p[i] = i;
  licz(p,0);
  cout << res << "\n";
}


Measured memory_bytes: 186296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    for (ll i = -200; i < 200; i++){
        ll a = pow(i, 5);
        for (ll j = -200; j < 200; j++){
            ll b = pow(j, 5);
            if(a - b == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  ll a[3*n];
  rep(i,3*n) cin >> a[i];
  sort(a,a+3*n);
  reverse(a,a+3*n);
  ll ans=0;
  rep(i,2*n){
    if(i%2==1) ans+=a[i];
  }
  cout << ans << endl;

  return 0;

}


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

int main(){
  int A, B; cin >> A >> B;
  double T8 = 0.08;
  double T10 = 0.1;
  int A_max = 0;
  int A_min = 0;
  int B_max = (B+1) / T10 -1;
  int B_min = B / T10;

  if ((A*100) % 8 == 0) A_min = A / T8;
  else A_min = (A / T8) + 1;

  if (((A+1)*100) % 8 == 0) A_max = (A+1) / T8 -1;
  else A_max = (A+1) / T8;

  if(A_max<B_min||B_max<A_min) cout << -1 << endl;
  else if(A_min<=B_min) cout << B_min << endl;
  else cout << A_min << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b;
  char ch;
  cin>>a>>ch>>b;
  if(ch=='+') cout<<a+b<<endl;
  if(ch=='-') cout<<a-b<<endl;
  if(ch=='*') cout<<a*b<<endl;
  if(ch=='/') cout<<a/b<<endl;
  return 0;
}
	


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(std::string A){
    vec<ll> counter(256);
    for(auto c: A){
        counter.at(c)++;
    }

    ll res = 0;
    for(char i='a'; i <= 'z'; i++){
        for(char j=i+1; j <= 'z'; j++){
            res += counter.at(i)*counter.at(j);
        }
    }

    res++;

    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string A;
    std::cin >> A;
    solve(A);
    return 0;
}


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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
#define FOR(i,a,b)      for (int i = a; i < b; i++)

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n,m,t;
	cin >> n >> m >> t;
	vector<int> ar(n),br(m);
	FOR(i,0,n){
		cin >> ar[i];
	}
	FOR(i,0,m){
		cin >> br[i];
	}
	FOR(i,1,n){
		ar[i] += ar[i-1];
	}
	FOR(i,1,m){
		br[i] += br[i-1];
	}
	int ans = 0;
	int cur = upper_bound(br.begin(),br.end(),t) - br.begin() - 1;
	ans = cur+1;
	FOR(i,0,n){
		if(t < ar[i])
			break;
		int tans = i+1;
		int add = upper_bound(br.begin(),br.end(),t-ar[i]) - br.begin();
		ans = max(ans,tans+add);
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6420
H,W,N=map(int,input().split())
D=dict()
for i in range(N):
  a,b=map(int,input().split())
  for p in range(-1,2):
    for q in range(-1,2):
      x=a+p
      y=b+q
      if 2<=x<=H-1 and 2<=y<=W-1:
        pos=(x,y)
        if pos in D:
          D[pos]+=1
        else:
          D[pos]=1
ans=[0]*10
V=list(D.values())
for v in V:
  ans[v]+=1
ans[0]=(H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define SWAP(x, y) do { char z = y; y = x; x = z; } while (0)
int main(void)
{
    string m("print");
    string p("print");
    string rv("reverse");
    string rp("replace");
    string str,o,rStr;
    int q,a,b;
    int i,j,k;
    cin>>str>>q>>o;
    while(q--) {
        //cout<<q;5
        if(m==o) {
            cin>>a>>b;
            FOR(i,a,b) cout<<str[i];
            cout<<endl;
        } else if(rv==o) {
            cin>>a>>b;
            //cout<<endl<<a<<b<<endl;
            for(i=a,j=b;i<j;i++,j--){
                //cout<<endl<<i<<j<<endl;
                SWAP(str[i],str[j]);
                //cout<<endl<<str[i]<<' '<<str[j]<<endl;
            }
        } else if(rp==o) {
            cin>>a>>b>>rStr;
            k=0;
            //cout<<a<<b<<rStr<<endl;
            while('\0'!=rStr[k]) {
                SWAP(str[a],rStr[k]);
                a++;
                k++;
            }
        }
        cin>>o;
        //cout<<endl<<o<<endl;
    }
}



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 102;
vector<int> info[MAX_N];

int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	while (cin >> N, N ){
		rep (i, N ) info[i].clear();
		rep (i, N ){
			int M; cin >> M;
			rep (j, M ){
				int p; cin >> p;
				p--;
				info[i].push_back (p );
			} // end rep
			sort (ALL (info[i] ) );
		} // end rep
		int K; cin >> K;
		vector<int> leak; leak.clear();
		rep (i, K ){
			int l; cin >> l;
			l--;
			leak.push_back (l );
		} // end rep
		sort (ALL (leak ) );
		int cnt = 0;
		int res = -1;
		rep (i, N ){
			int cur = 0;
			rep (j, leak.size() ){
				rep (k, info[i].size() ){
					if (info[i][k] == leak[j] ){
						cur++;
					} // end if
				} // end rep
			} // end rep
			if (cur == leak.size() ){
				res = i+1; cnt++;
			} // end if
		}// end rep
		if (cnt == 1 ){
			cout << res << endl;
		}else{
			cout << -1 << endl;
		} // end if
	} // end while
		
	return 0;
}

Measured memory_bytes: 1288
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    string s;
    cin >> s;

    int diff_min = 999;
    for(int i=0;i<s.size()-2;i++){
        int d = stoi(s.substr(i,3)) - 753;
        if(abs(diff_min) > abs(d))diff_min = d;
    }

    cout << abs(diff_min) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[0]*a[1]/2<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m, k = map(int, input().split())

friend = [0] * n
block = [0] * n

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
ab = [list(map(int, input().split())) for i in range(m)]
for a, b in ab:
    uf.union(a-1, b-1)
    friend[a-1]+=1
    friend[b-1]+=1

for i in range(k):
    c, d = map(int, input().split())
    if uf.same(d-1, c-1):
        block[c-1]+=1
        block[d-1]+=1

ans = []
for i in range(n):
    ans.append(uf.size(i) - friend[i] - block[i] -1 )
print(' '.join(list(map(str, ans))))

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

int main() {
  string str;
  int a=0;
  int n;
  int m;
  
  cin>>str;
  n=str.size();
  m=n/2;
  
  if(n%2!=0)
    a=1;
  
  for(int i=0;i<m;i++)
  {
    if(str.at(2*i)!='h')
    {a=1;
     break;}
    if(str.at(2*i+1)!='i')
    {a=1;
     break;
    }
  }
  if(a==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}


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

int main(){
  ll N,W; cin>>N>>W;
  vector<vector<ll>> dp(110,vector<ll>(100010,2147483640));
  ll w,v;
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    cin>>w>>v;
    for(int j=0;j<=100010;j++){
      if(j<v){
        dp[i+1][j]=dp[i][j];
        continue;
      }
      dp[i+1][j]=min(dp[i][j-v]+w,dp[i][j]);
    }
  }
  for(int i=100005;i>=0;i--){
    if(dp[N][i]<=W){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 87296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	std::string s, p;
	std::cin >> s >> p;

	s += s;
	s += s;

	if (s.find(p) <= s.length()) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Scanner;

public class Main {

	// he, his, hat は全て't'より若い文字コードを持つ
	private static final int[] PATTEN_THE_ = { 0, -12, -15 };
	private static final int[] PATTEN_THIS = { 0, -12, -11, -1 };
	private static final int[] PATTEN_THAT = { 0, -12, -19, 0 };

	private static enum WORD {
		THE_, THIS, THAT, OTHER
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		// Scanner sc;
		// ArrayList<String> words;
		String[] words;

		while ((line = br.readLine()) != null) {
			// Scanner は遅い
			// sc = new Scanner(line);
			// words = new ArrayList<String>();
			// while (sc.hasNext()) {
			// words.add(sc.next());
			// }
			words = line.split(" ");
			for (String word : words) {
				String check = word;
				WORD pattern = WORD.OTHER;
				int shift;
				if (word.endsWith("."))
					check = check.replace(".", "");
				if (check.length() == 3) {
					pattern = checkPattern(check, PATTEN_THE_);
				} else if (check.length() == 4) {
					pattern = checkPattern(check, PATTEN_THIS);
					if (pattern != WORD.THIS)
						pattern = checkPattern(check, PATTEN_THAT);
				}
				if (pattern == WORD.THE_ || pattern == WORD.THIS
						|| pattern == WORD.THAT) {
					shift = getNumberOfShift(word.charAt(0));
					System.out.println(decode(line, shift));
					break;
				}
			}
		}
	}

	public static WORD checkPattern(String word, int[] pattern) {

		WORD result = WORD.OTHER;

		boolean isMatch = false;

		int first = word.charAt(0);
		for (int i = 1; i < word.length(); i++) {
			int target = (int) word.charAt(i);
			if (target > first)
				target -= 26;
			if (target - first == pattern[i]) {
				isMatch = true;
			} else {
				isMatch = false;
				break;
			}
		}
		if (isMatch) {
			if (pattern == PATTEN_THE_)
				result = WORD.THE_;
			if (pattern == PATTEN_THIS)
				result = WORD.THIS;
			if (pattern == PATTEN_THAT)
				result = WORD.THAT;
		}
		return result;
	}

	public static int getNumberOfShift(char charOft) {
		int result;
		result = (int) (charOft - 't');
		return result;
	}

	public static String decode(String line, int shift) {
		char[] c = line.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if (c[i] >= 'a' && c[i] <= 'z') {
				c[i] = (char) (c[i] - shift);
				if (c[i] < 'a')
					c[i] = (char) (c[i] + 26);
				if (c[i] > 'z')
					c[i] = (char) (c[i] - 26);
			}
		}
		return String.valueOf(c);

		// StringBuilder sb = new StringBuilder();
		// for (int i = 0; i < line.length(); i++) {
		// char ch = line.charAt(i);
		// if (ch >= 'a' && ch <= 'z') {
		// ch = (char) ((int) ch - shift);
		// if (ch < 'a')
		// ch = (char) ((int) ch + 26);
		// if (ch > 'z')
		// ch = (char) ((int) ch - 26);
		// }
		// sb.append(ch);
		// }
		// return sb.toString();
	}
}

Measured memory_bytes: 17076
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        String[] st = br.readLine().split(" ");
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = Integer.parseInt(st[i]);
        }

        Object[] obj = selectionSort(data, n);
        data = (int[]) obj[0];
        bw.append("" + data[0]);
        for (int i = 1; i < n; i++) {
            bw.append(" " + data[i]);
        }
        bw.append("\n" + obj[1] + "\n");
        bw.flush();
    }

    static Object[] selectionSort(int[] data, int n) {
        Object[] obj = new Object[2];
        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            int min = i;
            boolean chk = false;
            for (int j = i; j < n; j++) {
                if (data[j] < data[min]) {
                    chk = true;
                    min = j;
                }
            }
            if (chk) {
                swap(data, i, min);
                count++;
            }
        }

        obj[0] = data;
        obj[1] = count;
        return obj;
    }

    static void swap(int[] data, int a, int b) {
        int tmp = data[a];
        data[a] = data[b];
        data[b] = tmp;
    }


}


Measured memory_bytes: 24376
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	double h,l,t;
	h=l=0;
	while(~scanf("%lf",&t)){
		if(l==0)l=t;
		h=max(h,t);
		l=min(l,t);
	}
	printf("%.1f\n",h-l);
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N, M;
vector<int> A;


signed main()
{
    cin >> N >> M;
    A.assign(M, 0);
    REP(i, N) {
        int K;
        cin >> K;
        REP(j, K) {
            int a;
            cin >> a;
            a--;
            A[a]++;
        }
    }
    int ans = 0;
    REP(i, M) { if(A[i] == N) { ans++; } }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0:
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1:
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2:
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3:
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        

def main():
    import random

    n = int(input())
    diceList = [[0 for _ in range(6)] for _ in range(n)]
    for i in range(n):
        diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5] = map(int, input().split())

    flag = 0

    # 2つ目以降のさいころが、以前のさいころと一致しているか確認していく。
    for i in range(1, n):
        if flag == 1:
            break
        else:
            dice_a = Dice(diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5])
            for j in range(i):
                dice_b = Dice(diceList[j][0],diceList[j][1],diceList[j][2],diceList[j][3],diceList[j][4],diceList[j][5])

                for _ in range(50):
                    if (dice_a.t, dice_a.s, dice_a.e, dice_a.w, dice_a.n, dice_a.b) == (dice_b.t, dice_b.s, dice_b.e, dice_b.w, dice_b.n, dice_b.b):
                        flag = 1
                        break
                    else:
                        seed = random.randint(0, 3)
                        dice_a.rot(seed)

    if flag == 0:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()



Measured memory_bytes: 8212