akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define end cout<<endl;

const int MAX = 1000001;
vector<long long >isprime(MAX , true); 
vector<long long >prime; 
vector<long long >SPF(MAX); 
void Seive(int N) 
{ 
    isprime[0] = isprime[1] = false ; 
   
    for (long long int i=2; i<N ; i++) 
    { 
        if (isprime[i]) 
        { 
            prime.push_back(i);  
            SPF[i] = i; 
        } 
  
        for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) 
        { 
            isprime[i*prime[j]]=false; 
   
            SPF[i*prime[j]] = prime[j] ; 
        } 
    } 
} 

ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0) 
        return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 

void solve(){
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n);
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	vector<vector<int>>dp(n,vector<int>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}

return 0;
}

Measured memory_bytes: 25608
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    bool f = false;
    rep(i, m+1)if(n * i == k)f = true;
    rep(i, n+1)if(m * i == k)f = true;

    REP(i, 1, n){
        ll sum = m * i;
        REP(j, 1, m){
            sum = sum - i + n - i;
            if(sum == k)f = true;
        }
    }
    cout << (f ? "Yes" : "No") << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int memo[100010];

int DP(int idx,const vector<vector<int>>& G)
{
	if(memo[idx]!=-1)return memo[idx];
	int res=0;
	for(auto e:G[idx])
	{
		chmax(res,DP(e,G)+1);
	}
	memo[idx]=res;
	return memo[idx];
}

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

	int N,M;
	cin>>N>>M;
	vector<vector<int>> G(N);

	int x,y;
	rep(i,0,M)
	{
		cin>>x>>y;
		x--,y--;
		G[x].push_back(y);
	}

	fill(memo,memo+100010,-1);

	int ans=0;
	rep(i,0,N)
	{
		chmax(ans,DP(i,G));
	}

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

Measured memory_bytes: 8576
package main

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

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


func main() {
	N := oneInt()
	var nums []int
	for index := 0; index < N; index++ {
		nums = append(nums, oneInt())
	}

	nums = sortAsc(nums)
	piv := len(nums) / 2
	s := nums[piv-1]
	b := nums[piv]

	if s == b {
		fmt.Print(0)
		return
	}
	fmt.Print(b - s)

}


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
int N;

int main()
{
  int n, i;
  int ret=0;

  cin >> N;
  multiset<string> S;
  string strin;
  for (i=0; i<N; i++) {
    cin >> strin;
    S.insert(strin);
  }
  multimap<int, string> mm;
  for (auto itr=S.begin(); itr!=S.end(); ) {
    string k;
    k=*itr;
    mm.insert(make_pair(S.count(k), k));
//    printf("%d %s\n", S.count(k), itr->c_str());
    advance(itr, S.count(k));
  }

  auto it = mm.end();
  it--;
  int num=it->first;
  auto pp = mm.equal_range(num);
  for (auto itr=pp.first ; itr != pp.second; itr++) {
    printf("%s\n", itr->second.c_str());
  }

  return 0;
}


Measured memory_bytes: 34560
from collections import defaultdict
from collections import deque

n, x, y = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(n-1):
    edges[i].append(i+1)

for i in range(1, n):
    edges[i].append(i-1)

edges[x-1].append(y-1)
edges[y-1].append(x-1)

count = defaultdict(int)


def bfs(start):
    dist = [10**4] * n
    dist[start] = 0
    todo = deque([])
    for to in edges[start]:
        todo.append([1, to])

    while todo:
        d, node = todo.popleft()
        if d >= dist[node]:
            continue

        dist[node] = d
        for to in edges[node]:
            todo.append([d+1, to])
    return dist


for start in range(n):
    dist = bfs(start)
    for d in dist:
        count[d] += 1

for k in range(1, n):
    res = count[k] // 2
    print(res)

Measured memory_bytes: 60468
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a*b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}

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

#define  ll long long
const int maxn = 2e5+5;

int n;
char s[maxn];
int black[maxn],white[maxn];

int main()
{
  ios::sync_with_stdio(false);
  cin >> n >> (s + 1);
  for(int i = 1 ; i <= n ; i++){
    black[i] = black[i-1];
    white[i] = white[i-1];
    if(s[i] == '#') black[i]++;
    else white[i]++;
  }
  //for(int i = 1 ; i <= n ; i++)
    //cout << black[i] ;
  int ans = maxn;
  for(int i = 1 ; i <= n ; i++){
    int temp = black[i] + white[n] - white[i];
    ans = min(ans,temp);
  }
  ans = min(ans,black[n]);
  ans = min(ans,white[n]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  ll mod=1000000007;
  ll t=1;
 ll n=1;
  ll e=1;
  for(ll i=0;i<N;i++) {
t*=10;
    n*=9;
    e*=8;
    t%=mod;
    n%=mod;
    e%=mod;
  }
  ll ans=t-n-(n-e);
  if(ans<0) {
while(ans<0) {
ans+=mod;
}
  }
  
  cout<<ans<<endl;
}
    
  
  
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h1,m1,h2,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << 60* h2 + m2 -  (60 * h1 + m1) - k << endl;
}

Measured memory_bytes: 3656
object Main extends App {
  val nxtInput = scala.io.StdIn.readLine()
  val nxtArray = nxtInput.split(" ").map(_.toInt).toVector

  val n = nxtArray(0)
  val x = nxtArray(1)
  val t = nxtArray(2)
  var tempKosuu = 0
  var result = 0

  while(n > tempKosuu) {
    tempKosuu = tempKosuu + x
    result = result + t
  }
  println(result)
}

Measured memory_bytes: 54536
#include<bits/stdc++.h>
using namespace std;
int n,m;
string b[105];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>b[i];
    sort(b,b+n);
    for(int i=0;i<n;i++) cout<<b[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n + 1];
    for(int i = 1;i < n + 1;i++)
    {
        cin >> a[i];
    }
    int b[n + 1] = {};
    vector<int> v;
    for(int i = n;i >= 1;i--)
    {
        int count = 0;
        for(int j = i;j < n + 1;j += i)
        {
            count += b[j];
        }
        if(count % 2 == a[i])
        {
            b[i] = 0;
        }
        else
        {
            b[i] = 1;
            v.push_back(i);
        }
    }
    cout << v.size() << "\n";
    for(int i = 0;i < v.size();i++)
    {
        cout << v[i] << " ";
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	ls := make([]int, n)
	for i := 0; i < n; i++ {
		ls[i] = eGetInt(scanner)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	count := 0
	for i := 0; i < n-2; i++ {
		a := ls[i]
		for j := i + 1; j < n-1; j++ {
			b := ls[j]
			left := j + 1
			right := n
			mid := (left + right) / 2
			for right-left >= 1 {
				if a < b+ls[mid] {
					left = mid + 1
				} else {
					right = mid
				}
				mid = (left + right) / 2
			}
			count += left - (j + 1)
			// for k := j + 1; k < n; k++ {
			// 	c := ls[k]
			// 	ここを二分探索で検索可能
			//
			// 	if b+c > a {
			// 		count++
			// 	} else {
			// 		break
			// 	}
			// }
		}
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	int k; cin >> k;
	int cnt = 1;
	for (int i = a; i <= b; i++) {
		if (cnt <= k || b - k + 1 <= i) {
			cout << i << endl;
		}
		cnt++;
	}
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
ll gcd(ll a, ll b){
  if(a==0) return b;
  else return gcd(b%a, a);
}
int main(){
  	ll K;
    cin >> K;

    ll memo[K+1][K+1];
    for(ll i=1;i<=K;i++){
      for(ll j=1;j<=K;j++){
        memo[i][j] = gcd(i, j);
      }
    }

    ll sum = 0;

    for(ll b=1;b<=K;b++){
      for(ll c=1;c<=K;c++){
        ll tmp = memo[b][c];
        for(int a=1;a<=K;a++){
          sum += memo[a][tmp];
        }
      }
    }

    cout << sum <<endl;
  	return 0;
}

Measured memory_bytes: 3876
import sys
def input():
    return sys.stdin.readline()[:-1]
M=int(input())
S,s=0,0
for i in range(M):
    d,c=map(int,input().split())
    S+=d*c
    s+=c
if S%9==0:
    a=S//9-1
else:
    a=S//9
a+=s-1
print(a)

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	int n;
	cin >> n;
	ll res = 0;
	FOR(i, 1, n) {
		if (i % 3 != 0 && i % 5 != 0) {
			res += i;
		}
	}
	pv(res)

	return(0);
}

Measured memory_bytes: 3620
# 2019/07/31

from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

g1=[0]*n
g2=[0]*n
g1[0]=a[0]
g2[-1]=a[-1]


i=1
j=n-2
while i<n and j>-1:
    g1[i]=gcd(g1[i-1],a[i])
    g2[j]=gcd(g2[j+1],a[j])
    i+=1;j-=1

ans=[0]*n
ans[0]=g2[1]
ans[-1]=g1[-2]

for i in range(1,n-1):
    ans[i]=gcd(g2[i+1],g1[i-1])

print(max(ans))

Measured memory_bytes: 16160
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w, n;
  cin >> h >> w >> n;
  vl ans(10);
  map<pii, int> mp;
  rep(i,n){
    int a, b;
    cin >> a >> b;
    
    rep(j,3){
      rep(k,3){
        if(0<a-j && a-j<h-1 && 0<b-k && b-k<w-1) mp[pii(a-j,b-k)]++;
      }
    }
  }
  for(auto itr = mp.begin();itr != mp.end(); itr++){
    ans[itr->second]++;
  }
  ll sum = 0;
  rep(i,10) sum += ans[i];
  cout << (h-2)*(w-2)-sum << endl;
  rep(i,9) cout << ans[i+1] << endl;
	return 0;
}


Measured memory_bytes: 56576
// A - 高橋君とホテルイージー

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	int ans = 0;

	for (int i=1; i<=N; i++) {
		if (i <= K) ans += X;
		else ans += Y;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long dp[101][2];

int main() {
	long long N, K;
	cin >> N >> K;
	vector<long long>A(N);
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
	}
	for (int n = 0; n < 101; ++n) {
		dp[n][0] = dp[n][1] = -1;
	}
	dp[0][0] = 0;
	for (int n = 0; n < 45; ++n) {
		long long mask = 1LL << (44 - n);
		long long count = 0;
		for (int i = 0; i < N; ++i) {
			if (A[i] & mask) {
				count++;
			}
		}
		if (dp[n][1] >= 0) {
			dp[n + 1][1] = max(dp[n + 1][1], dp[n][1] + mask * max(count, N - count));
		}
		if (dp[n][0] >= 0) {
			if (K&mask) {
				dp[n + 1][1] = max(dp[n + 1][1], dp[n][0] + mask * count);
				dp[n + 1][0] = max(dp[n + 1][0], dp[n][0] + mask * (N - count));
			}
			else {
				dp[n + 1][0] = max(dp[n + 1][0], dp[n][0] + mask * count);
			}
		}

	}
	cout << max(dp[45][0], dp[45][1]) << endl;
	return 0;
}


Measured memory_bytes: 4040
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
using namespace std;
map <string ,int> ml;
int n,m;
char t[105][105],s[105][105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{scanf("%s",s[i]);ml[s[i]]++;}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{scanf("%s",&t[i]);ml[t[i]]--;}
	int max_n=0;
	for(int i=1;i<=m;i++)
	{
		if(ml[t[i]]>max_n) max_n=ml[t[i]];
	}
	for(int i=1;i<=n;i++)
	{
		if(ml[s[i]]>max_n) max_n=ml[s[i]];
	}
	printf("%d",max_n);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N, M;
    cin >> N >> M;
    vector<ll> x(N), y(N), z(N);

    rep(i, 0, N) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;

    for(int ix = 0; ix < 2; ix++){
        for(int iy = 0; iy < 2; iy++){
            for(int iz = 0; iz < 2; iz++){
                if(ix){
                    rep(i,0,N) x[i] *= -1;
                }
                if(iy){
                    rep(i,0,N) y[i] *= -1;
                }
                if(iz){
                    rep(i,0,N) z[i] *= -1;
                }

                vector<ll> xyz(N);
                rep(i,0,N){
                    xyz[i] = x[i] + y[i] + z[i];
                }
                sort(all(xyz));
                reverse(all(xyz));
                ll tmp = 0ll;
                rep(i,0,M){
                    tmp += xyz[i];
                }

                ans = max(tmp,ans);






                if(ix){
                    rep(i,0,N) x[i] *= -1;
                }
                if(iy){
                    rep(i,0,N) y[i] *= -1;
                }
                if(iz){
                    rep(i,0,N) z[i] *= -1;
                }
            }
        }
    }



    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>	
#include<vector>

using namespace std;
#define pi 3.141592
int main() {
	int n,m,a,day;
	cin >> n>>m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		n -= a;
	}
	if (n < 0)n = -1;
	cout << n;
}

Measured memory_bytes: 3636
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = 10**11+1
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

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

    # divisors.sort()
    return divisors


n,mm = m()
ke = set([i+1 for i in range(n)])
bo = [[] for i in range(n)]
dp = [Max for i in range(2**n)]
kkk = []
dp[0] = 0
waa = set()
for i in range(mm):
    a,b = m()
    c = l()
    bit = 0
    on = 0
    for i in c:
        bit |= 1 << (i-1)
    waa = waa | set(c)
    for j in range(2**n):
        dp[j|bit] = min(dp[j|bit] ,dp[j] + a)
    
kkk.sort(key = lambda x:x[1])
if ke != waa:
    print(-1)
else:
    print(dp[-1])
            




Measured memory_bytes: 77524
#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;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    
    return 0;
}



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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
vector<lint> a;
lint memo[3001][3001];

lint solve(bool turn, int left, int right){
    if(left == right){
        return 0;
    }
    if(memo[left][right] < LLINF){
        return memo[left][right];
    }
    if(turn){
        return memo[left][right] = max(solve(false, left + 1, right) + a[left], solve(false, left, right - 1) + a[right - 1]);
    }else{
        return memo[left][right] = min(solve(true, left + 1, right) - a[left], solve(true, left, right - 1) - a[right - 1]);
    }
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i, n){
        cin >> a[i];
    }
    fill(memo[0], memo[3001], LLINF);
    lint ans = solve(true, 0, n);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

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

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

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

int N;
vector<vector<int>> G;
vector<vector<ll>> dp;

void rec(int parent, int current) {
    if (G[current].size() == 1 && G[current][0] == parent) {
        dp[current][0] = 1;
        dp[current][1] = 1;
    }

    if (G[current].size() == 0) {
        dp[current][0] = 1;
        dp[current][1] = 1;
    }

    for (int i = 0; i < G[current].size(); i++) {
        int next = G[current][i];
        if (next == parent) continue;
        rec(current, next);
    }
    if (parent == -1 ) return;
    dp[parent][0] *= dp[current][1];
    dp[parent][0] %= mod;
    dp[parent][1] *= (dp[current][1] + dp[current][0])%mod;
    dp[parent][1] %= mod;
    return;
}

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

    cin >> N;
    G.assign(N, vector<int>());

    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dp.assign(N + 1, vector<ll>(2, 1));

    rec(-1, 0);

    cout << (dp[0][0] + dp[0][1]) % mod << endl;
    
    return 0;
}

Measured memory_bytes: 18068
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
	public static void main(String[] args){
		int i, j, q, order, x, counter = 0;
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		TreeSet<Integer> set = new TreeSet<Integer>();
		try (Scanner sc = new Scanner(System.in)) {
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				order = sc.nextInt();
				x = sc.nextInt();
				switch(order) {
				case 0 :
					counter++;
					if(!set.add(x)) {
						if(map.containsKey(x)) {
							map.compute(x, (key, old) -> old + 1);
						}else {
							map.put(x, 1);
						}
					}
					System.out.println(counter);
					break;
				case 1 :
					if(set.contains(x)) {
						if(map.containsKey(x)) {
							System.out.println(map.get(x) + 1);
						}else {
							System.out.println(1);
						}
						
					}else {
						System.out.println(0);
					}
					break;
				case 2 :
					if(set.remove(x)) {
					    counter--;
						if(map.containsKey(x)) {
							counter -= map.remove(x);
						}
					}
					break;
				case 3 :
					for(Integer output : set.subSet(x, true, sc.nextInt(), true)) {
						System.out.println(output);
						if(map.containsKey(output)) {
							for(j = 0; j < map.get(output); j++) {
								System.out.println(output);
							}
						}
					}
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 180512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll dp[200200]={};
int main(){
    fast_io
    
    int n;
    cin>>n;
    int a[n];
    rep(i,n) {
        cin>>a[i];
        dp[a[i]]++;
    }
    ll sum=0;
    rep(i,n+1){
        ll tmp=dp[i]*(dp[i]-1)/2;
        sum+=tmp;
    }
    rep(i,n){
        ll ans=sum-(dp[a[i]]-1);
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
    string S, T; cin >> S >> T;
    bool ans = false;
    for (int i = 0; i < S.size(); i++) {
        if (S == T) {
            ans = true;
            break;
        }

        S = S.back() + S.substr(0, S.size() - 1);
    }
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

using namespace std;

string a , b;

int main()
{
    int i , n;
    cin >> a >> b;
    n = b.size();
    for(i = 0 ; i < n - 1 && a[i] == b[i] ; i++)
            ;
    if(i == n - 1)
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

lf dp[310][310][310];
int c[4];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        lf n;
        cout<<pset(10);
        cin>>n;
        rep(i, n)
        {
            int x;
            cin>>x;
            c[x]++;
        }

        for(ll k=0; k <= c[3]; k++)
        {
            for(j=0; j <= c[3] + c[2]; j++)
            {
                for(i=0; i <= c[1] + c[2] + c[3];i++)
                {
                    if(i == 0 and j == 0 and k == 0)
                        continue;

                    lf sum = (lf)i + (lf)j + (lf)k;
                    dp[i][j][k] += (n/((lf)i + (lf)j + (lf)k));
                    if(i > 0)
                        dp[i][j][k] += (((lf)i/(lf)sum) * (dp[i-1][j][k]));
                    if(j > 0)
                        dp[i][j][k] += (((lf)j/(lf)sum) * (dp[i+1][j-1][k]));
                    if(k > 0)
                        dp[i][j][k] += (((lf)k/(lf)sum) * (dp[i][j+1][k-1]));
                }
            }
        }

        cout<<dp[c[1]][c[2]][c[3]]<<endl;
    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 452864
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int n;
  int ln;
  string s,t;
  while(cin>>n&&n){
    cin>>s;
    for(i=0;i<n;i++){
      ln=s.length();
      t="";
      for(j=0;j<ln;j=k){
	for(k=j+1;k<ln&&s[k-1]==s[k];k++);
	if(k-j==100)
	  t+="100";
	else if(k-j>9){
	  t+=(char)((k-j-(k-j)%10)/10+'0');
	  t+=(char)((k-j)%10+'0');
	}else
	  t+=(char)(k-j+'0');
	t+=(char)s[j];
      }
      s=t;
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b;
    cin >> a >> b;
    
    cout << max(0, a-b) << endl;
    

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int h, w;

        while (true)
        {
            string[] num = Console.ReadLine().Split(' ');
            h = int.Parse(num[0]);
            w = int.Parse(num[1]);

            if (h == 0 && w == 0)
            {
                break;
            }

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    Console.Write("#");
                }
                Console.WriteLine("");
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 8972
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;



int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	double arc;
	double rad;

	if (2 * x > a * a * b) {
		//printf("more than half\n");
		double t = 2.0 * ((double)b - (double)x / (a * a));
		arc = t / a;
		//printf("%.12f\n", arc);
		rad = atan(arc);
	} else {
		//printf("less than half\n");
		double t = ((double)x * 2.0 )/ ((double)a * b);
		//printf("t = %.12f\n", t);
		arc = (double)b / t;
		//printf("arc = %.12f\n", arc);
		rad = atan(arc);
	}

	printf("%.12f", rad / PI * 180);

	return 0;
}



Measured memory_bytes: 384
h, w, hh, ww = [int(i) for i in input().split()]
area = [h*w, hh*ww]
m = (h//hh) * (w // ww)
a_inv = (area[0] / m - area[1])
if(a_inv <= 0):
    print("No")
else:
    print("Yes")
    a = a_inv ** -1
    if(int(a) < a):
        a = int(a) + 1
    else:
        a = int(a)
    b = (area[1] - 1) * a + 1
    while(b >= (area[0]/m - 1)*a):
        a += 1
        b = (area[1] - 1) * a + 1
    a = str(a)
    b = str(-b)
    for i in range(h):
        ret = [None]*w
        for j in range(w):
            if((i+1) % hh == 0 and (j+1) % ww == 0):
                ret[j] = b
            else:
                ret[j] = a
        print(" ".join(ret))

Measured memory_bytes: 4212
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int A, B, C;
    int x = 0;
    cin >> A >> B >> C;
    if(A%2 == B%2 && C%2 != B%2) {
        A++;
        B++;
        x++;
    }
    else if(A%2 == C%2 && B%2 != C%2) {
        A++;
        C++;
        x++;
    }
    else if(A%2 != B%2 && B%2 == C%2) {
        B++;
        C++;
        x++;
    }
    
    if(A <= B && B <= C){
        x += (C-A)/2;
        x += (C-B)/2;
    }
    else if(A <= C && C <= B){
        x += (B-A)/2;
        x += (B-C)/2;
    }
    else if(B <= A && A <= C){
        x += (C-A)/2;
        x += (C-B)/2;
    }
    else if(B <= C && C <= A){
        x += (A-C)/2;
        x += (A-B)/2;
    }
    else if(C <= A && A <= B){
        x += (B-C)/2;
        x += (B-A)/2;
    }
    else if(C <= B && B <= A){
        x += (A-C)/2;
        x += (A-B)/2;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3640
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

void solve() {
	
	LL n, k;
	cin>>n>>k;
	LL ans;
	if(n>k) {
		ans = min(n%k, abs(k - n%k));
	} else if(n<k) {
		ans = min(n, k-n);
	} else ans = 0;
	cout<<ans<<endl;
	
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll g[10][10];

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin >> n;
    vl a(n);
    rep(i,0,n)cin >> a[i];
    ll m = MOD;
    ll ans = 0;
    rep(i,0,n){
        ans += (a[i] <= m);
        chmin(m,a[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 4768
#include <stdio.h>

int main(void){
int n=0,m=0;
	while(scanf("%d",&n),n){
		char change[100][2];
		char s;
		for(int i=0;i<n;i++)
			scanf(" %c %c", &change[i][0], &change[i][1]);
		scanf("%d",&m);
		for(int j=0;j<m;j++){
			scanf(" %c", &s);
			for(int k=0;k<n;k++){
				if(s==change[k][0]){
						s=change[k][1];
						break;
				}	
			}
			printf("%c", s);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n+1];
    for(long long int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    unordered_map<long long int ,int>m;
    vector<long long int >l;
    l.push_back(1);
    m[1]=1;
    long long int t=a[1];
    while(1)
    {
        if(m.count(t)==0)
        {
            l.push_back(t);
            m[t]=1;
            t=a[t];
        }
        else
        {
            break;
        }
    }
    long long int ctr=0;
    /*for(auto x:l)
    {
        cout<<x<<"-";
         
    }*/
    for(auto x:l)
    {
         
        if(t!=x)
        {
            ctr++;
        }
        else
        {
            break;
        }
    }
    //cout<<ctr<<endl;
    long long int d=l.size()-ctr;
    if(k<=ctr)
    {
        cout<<l[k]<<endl;
    }
    else
    {
        k=k-ctr;
        cout<<l[ctr+k%d];
    }

    

    return 0;
}

Measured memory_bytes: 14460
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = max(a * b, a + b);
    int d = max(a - b, c);
    cout << d << endl;
}

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


int main() {
  int n,a;
  string s("APPROVED");
  cin>>n;
  for(int i=0; i<n;i++){
 
    cin>>a;
    if(a%2==0&&a%3!=0&&a%5!=0){
      s=("DENIED");
      break;
    } else{continue;}
  }
  cout<<s;
}






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

int main() {

  int A,B;
  while(1) {
  cin >> A >> B;
  if(A == 0 && B == 0) break;

  int ans[3] ={};
  B -= A;
  while(B != 0) {
    if(B >= 1000) {
      ans[2]++;
      B -= 1000;
    }
    else if(B >= 500) {
      ans[1]++;
      B -= 500;
    }
    else if(B >= 100) {
      ans[0]++;
      B -=100;
    }
  }

  cout << ans[0] <<" "<<ans[1]<<" "<<ans[2]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>

typedef long long ll;

using namespace std;

struct PA{
  vector<pair<int,int> > way;
  bool kaku;
  ll d;
  ll sumd;

  PA(){
    kaku=false;
  }
}park[100000];


int main(){
  int n,m,c,a,b,d;
  ll sumd=0,ans=0;
  priority_queue<pair<ll,int> > pq;
  bool bk[100000]={0};

  scanf("%d%d%d",&n,&m,&c);

  for(int i=0;i<m;i++){
    scanf("%d%d%d",&a,&b,&d);
    park[a-1].way.push_back(make_pair(b-1,d));
    park[b-1].way.push_back(make_pair(a-1,d));
    sumd+=(ll)d;
  }

  park[0].kaku=true;
  park[0].d=0;
  for(int i=0;i<park[0].way.size();i++)
    pq.push(make_pair(-park[0].way[i].second,park[0].way[i].first));
    
    
  while(!pq.empty()){

    pair<ll,int> p = pq.top();
    pq.pop();

    if(park[p.second].kaku) continue;
    park[p.second].kaku=true;
    park[p.second].d=(-p.first);
      
    for(int i=0;i<park[p.second].way.size();i++)
      pq.push(make_pair(-park[p.second].way[i].second+p.first,
			park[p.second].way[i].first));
  }
  
    
  vector<pair<ll,ll> > kyori;
  for(int i=0;i<n;i++){
    kyori.push_back(make_pair(park[i].d,i));
  }

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


  for(int i=0;i<(int)kyori.size();i++){
    ll sum=0;
    for(int j=0;j<(int)park[kyori[i].second].way.size();j++)
      if(bk[park[kyori[i].second].way[j].first]){
	sum+=(ll)park[kyori[i].second].way[j].second;
      }
    if(i>0)
      sum+=kyori[i-1].second;
    bk[kyori[i].second]=true;
    kyori[i]=make_pair(kyori[i].first,sum);
  }

  ans=sumd;
  for(int i=0;i<n;i++){
    ans=min(ans,kyori[i].first*c+sumd-kyori[i].second);
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 19492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<ll,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=205,M=1e7+10;
int n,cc,tt,a[N],b[M],vis[M],pr[M],hd[N],vv[N],lk[N];
struct E{int v,nxt;}e[N*N];
inline void add(int u,int v){e[++tt]=(E){v,hd[u]};hd[u]=tt;}
void init(int n)
{
	vis[1]=1;
	rep(i,2,n)
	{
		if(!vis[i])pr[++cc]=i;
		for(int j=1;j<=cc&&1ll*i*pr[j]<=n;j++)
		{
			vis[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	vis[2]=1;
}
bool dfs(int x)
{
	for(int i=hd[x],y;i;i=e[i].nxt)if(!vv[y=e[i].v])
	{
		vv[y]=1;
		if(!lk[y]||dfs(lk[y])){lk[y]=x;return 1;}
	}
	return 0;
}
int main()
{
	init(1e7+5);n=rd();
	rep(i,1,n)a[i]=rd(),b[a[i]]^=1;
	n=0;rep0(i,1,M)if(b[i]!=b[i-1])a[++n]=i;
	int s=0,n1=0,n2=0;
	rep(i,1,n)if(a[i]&1)n1++;else n2++;
	rep(i,1,n)rep(j,i+1,n)if(!vis[abs(a[i]-a[j])])add(i,j),add(j,i);
	rep(i,1,n)if(a[i]&1){memset(vv,0,sizeof(vv));s+=dfs(i);}
	n1-=s;s=n-s+(n1&1);printf("%d\n",s);return 0;
}


Measured memory_bytes: 81920
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


char buf[10000];
int main(void) {
  scanf("%*s%s%*s", buf);
  printf("A%cC\n", buf[0]);
  return 0;
}


Measured memory_bytes: 128
k,x=(int(x)for x in input().split())

i=-1*k+1

ans=[] #空のリストを作成

for i in range (-1*k+1,k):
    #print(x+i)
    ans.append(x+i)
    i=i+1
#リストの中身はfor文内ではint型（計算のため）

ans_str = [str(n) for n in ans]
#リストの中身を文字列に換える
wer=' '.join(ans_str)
#空白文字で連結
print(wer)


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

using ll=long long; 

int f(string a, string b){
	int cnt=0;
	map<char, bool> match;
	//cout<<a<<" "<<b<<endl;
	for(int i=0; i<int(a.size()); i++){
		for(int j=0; j<int(b.size()); j++){
			//cout<<a[i]<<" "<<b[j]<<endl;
			if(a[i]==b[j]){
				match[a[i]]=1;
				//cout<<a[i]<<endl;
			}
		}
	}
	for(char c='a'; c<='z'; c=char(c+1)){
		if(match[c]){
			//cout<<c<<endl;
			cnt++;
		}
	}
	return cnt;
}

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int maxv=-1;
	for(int i=1; i<s.size(); i++){
		maxv=max(maxv, f(s.substr(0,i), s.substr(i,n-i)));
	}
	cout<<maxv<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256