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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

bool isPalindrome(string s) {
    string ss = s;
    reverse(all(s));
    if (ss == s) return true;
    else return false;
}

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if (!isPalindrome(s)) ans = false;
    if (!isPalindrome(s.substr(0, (s.size()-1)/2))) ans = false;
    if (!isPalindrome(s.substr(s.size()/2+1, (s.size()-1)/2))) ans = false;
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#h,w = [int(i) for i in readline().split()]

n = int(input())
c = [chr(ord("a")+i) for i in range(20)]

ans = []
def dfs(x,i,v):
    if v==n:
        ans.append(x)
        return
    #print(x,i,v)
    for j in range(i+1):
        dfs(x+c[j],i,v+1)
    dfs(x+c[i+1],i+1,v+1)


dfs("",-1,0)

print(*sorted(ans),sep="\n")










Measured memory_bytes: 14476
#include <iostream>

#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<=(int)(n-1);i++)

int main() {
	int N;
	cin>>N;
	int a[N];
	rep(i,N) cin>>a[i];
	sort(a,a+N);
	reverse(a,a+N);
	int A = 0;
	rep(i,N) A += a[i];
	int B = 0;
	rep(i,N/2) B += a[2*i+1];
	cout<<A-2*B<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
ma = [["#" for _ in range(w+2)] for _ in range(h+2)]
for i in range(h):
    tmp = list(input())
    for j in range(w):
        ma[i+1][j+1] = tmp[j]
ans = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if ma[i][j] == "#":
            continue
        elif ma[i][j] == ".":
            p = [[-1 for _ in range(w+2)] for _ in range(h+2)]
            p[i][j] = 0
            q = deque()
            q.append([i, j])
            while q:
                y, x = q.popleft()
                if ma[y+1][x] == "." and p[y+1][x] == -1:
                    p[y+1][x] = p[y][x] + 1
                    q.append([y+1, x])
                if ma[y-1][x] == "." and p[y-1][x] == -1:
                    p[y-1][x] = p[y][x] + 1
                    q.append([y-1, x])
                if ma[y][x+1] == "." and p[y][x+1] == -1:
                    p[y][x+1] = p[y][x] + 1
                    q.append([y, x+1])
                if ma[y][x-1] == "." and p[y][x-1] == -1:
                    p[y][x-1] = p[y][x] + 1
                    q.append([y, x-1])
            for l in range(1, h+1):
                ans = max(ans, max(p[l]))
            # ans = max(ans, max(max(p)))
print(ans)

Measured memory_bytes: 9496
#include <stdio.h>

int main(void)
{
    int min, max, n, m, i, l, r, result;

    if(scanf("%d %d", &n, &m) == 1);
    min = 1; max = n;

    for(i = 1; i <= m; i++)
    {
        if(scanf("%d %d", &l, &r) == 1);
        if(min < l) min = l;
        if(max > r) max = r;
    }

    result = (max - min + 1) > 0 ? (max - min + 1) : 0;
    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

long lucas(long l0, long l1, int n)
{
        long res;

        if (n == 1)
                return l1;
        else {
                res = l0 + l1;
                n--;
        }

        return lucas(l1, res, n);
}

int main()
{
        int n;
        cin >> n;
        VB(lucas(2, 1, n));
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

void hoge(int& y, int& m, int& d) {
	d++;
	int x = (y % 3 != 0 && m % 2 == 0) ? 19 : 20;
	if (d <= x) return;
	d = 1;
	m++;
	if (m <= 10) return;
	m = 1;
	y++;
}

int main() {
	int n; cin >> n;
	while (n--) {
		int Y, M, D; cin >> Y >> M >> D;
		int cnt = 0;
		while (Y < 1000) {
			hoge(Y, M, D);
			cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 2e5 + 10 , N = 3e5 , mod = 1e9 + 7 , INF = 1e8 + 5e7;

ll lcm(ll a , ll b) {
    return (a * b) / __gcd(a , b);
}

int main() {
    ll x;
    ll cnt = 0 , sum = 0;
    cin >> x;
    for (ll i = 0; i < INF; ++i) {
        sum += x;
        cnt++;
        if(sum % 360 == 0){
            cout << cnt << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include <cassert>
#include <iostream>
#include <vector>

using llong = long long;
const llong MOD = 1.0e+9 + 7;

int main() {
  // Input
  int numRow;
  int numCol;
  std::cin >> numRow >> numCol;
  assert(2 <= numRow and numRow <= 1000);
  assert(2 <= numCol and numCol <= 1000);
  std::vector<std::string> grid(1 + numRow + 1);
  for (int i = 1; i <= numRow; ++i) {
    std::cin >> grid[i];
    assert(static_cast<int>(grid[i].size()) == numCol);
    grid[i].insert(grid[i].begin(), '-'); // use 1-indexed string
    grid[i].push_back('-');
  }
  for (int j = 0; j <= numCol + 1; ++j) {
    grid[0].push_back('-');
    grid[numRow + 1].push_back('-');
  }

  // Initialization
  std::vector<std::vector<llong>> dp(1 + numRow + 1);
  for (int i = 1; i <= numRow; ++i) {
    dp[i].assign(1 + numCol + 1, 0);
  }

  // Initial condition
  dp[1][1] = 1;

  // DP main
  for (int i = 1; i <= numRow; ++i) {
    for (int j = 1; j <= numCol; ++j) {
      assert(grid[i][j] == '.' or grid[i][j] == '#');
      if (grid[i + 1][j] == '.') {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= MOD;
      }
      if (grid[i][j + 1] == '.') {
        dp[i][j + 1] += dp[i][j];
        dp[i][j + 1] %= MOD;
      }
    }
  }

  // Output
  std::cout << dp[numRow][numCol] << std::endl;

  return 0;
}


Measured memory_bytes: 9216
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();

        int max = 0;
        for (int rightStart = 1; rightStart <= n - 1; rightStart++) {
            int[] leftCount = new int['z' - 'a' + 1];
            int[] rightCount = new int['z' - 'a' + 1];
            for (int i = 0; i < n; i++) {
                int charInd = s.charAt(i) - 'a';
                if (i < rightStart) {
                    leftCount[charInd]++;
                } else {
                    rightCount[charInd]++;
                }
            }

            int total = 0;
            for (char ch = 'a'; ch <= 'z'; ch++) {
                if (leftCount[ch - 'a'] > 0 && rightCount[ch - 'a'] > 0) {
                    total++;
                }
            }
            if (total > max) {
                max = total;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23892
/* created   : 2019-10-30 00:36:13
 * accepted  : 2019-10-30 10:14:34
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

const int N = 625;
vector<int> g[N];
int n;
int m;

vector<double> expect(const pair<int, int>& ignore) {
  vector<double> dp(n);
  for (int u = n - 2; u >= 0; u--) {
    double cur = 0;
    int cnt = 0;
    for (auto v : g[u]) {
      if (u == ignore.x && v == ignore.y) {
        continue;
      }
      cnt++;
      cur += dp[v];
    }
    dp[u] = cur / cnt + 1;
  }
  return dp;
}

void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
  }
  vector<double> dp = expect({-1, -1});
  trace(dp);
  double ans = dp[0];
  for (int u = 0; u < n - 1; u++) {
    double mx = 0;
    int ix = -1;
    for (auto v : g[u]) {
      if (dp[v] > mx) {
        mx = dp[v];
        ix = v;
      }
    }
    if (g[u].size() <= 1) {
      continue;
    }
    vector<double> np = expect({u, ix});
    ans = min(ans, np[0]);
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <vector>
#include <algorithm>

std::vector<int> children[100005];

int hs[100005];

void dfs(int node){
  std::vector<int> layer;
  for(int child:children[node]){
    dfs(child);
    layer.push_back(hs[child]);
  }
  std::sort(layer.begin(),layer.end());
  for(int i=0;i<layer.size();i++){
    hs[node]=std::max<int>(hs[node],layer[i]+layer.size()-i);
  }
}

int main(){
  int N;
  scanf("%d",&N);
  for(int i=1;i<N;i++){
    int A;
    scanf("%d",&A);
    A--;
    children[A].push_back(i);
  }
  dfs(0);
  printf("%d\n",hs[0]);
  return 0;
}


Measured memory_bytes: 13952
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  long long int x;
  scanf("%lld", &x);

  long long int ans = x + 1;
  for (long long int i = 1; i * i <= x; i++)
  {
    if (x % i != 0)
      continue;
    ans = min(x / i + i, ans);
  }
  printf("%lld\n", ans - 2);
  return 0;
}


Measured memory_bytes: 128
#include "stdio.h"

long long int letter;
long long int num[10];
long long int fig[10][10];
long long int ans = 0;
int n;
long long int box = 1;

void Cal_Fig() {
	for (int i = 0; i < n; i++) {
		fig[i][i] = num[i];
		for (int j = i+1; j < n; j++) {
			fig[i][j] = fig[i][j-1]*10;
			fig[i][j] += num[j];
		}
	}
}

long long int power(int a) {
	int m = 1;
	for (int i = 0; i < a; i++) {
		m*=2;
	}
	return m;
}

long long int sum(int a, int b) {
	return power(a - 1)*power(n - b - 2);
}

int main() {
	scanf("%lld", &letter);
	for (int i = 0;; i++) {
		if (box > letter) {
			n = i;
			break;
		}
		box *= 10;
	}
	for (int i = n-1; i >=0; i--) {
		num[i] = letter % 10;
		letter /= 10;
	}
	Cal_Fig();
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			ans += fig[i][j] * sum(i, j);
		}
	}
	printf("%lld", ans);
	return 0;
}

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

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

  int n, m;
  cin >> n >> m;
  vector<int> likes(m + 1, 0);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int like;
      cin >> like;
      likes[like]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    if (likes[i] == n) {
      ++ans;
    }
  }
  cout << ans << "\n";
}


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

int main() {
	int n, w;
	cin >> n >> w;
	long long int dp[w + 1];
	memset(dp, 0, sizeof(dp));
	for(int i = 0; i < n; i++){
		long long int m, v;
		cin >> m >> v;
		for(int j = w - m; j >= 0; --j){
			dp[j + m] = max(dp[j + m], dp[j] + v);
		}
	}
	cout << *max_element(dp, dp+w+1) << "\n";
	return 0;
}

Measured memory_bytes: 4376
#include<stdio.h>
#include<string.h>
int main()
{
    int N,i,j,t;
    int a[103],sum;
    while(scanf("%d",&N)!=EOF)
    {
        memset(a,0,sizeof(a));
        sum=0;
        for(i=1;i<=N;i++)
            scanf("%d",&a[i]);
        for(i=1;i<=N-1;i++)
        {
            for(j=N;j>=i+1;j--)
            {
                if(a[j]>a[j-1])
                {
                    t=a[j];
                    a[j]=a[j-1];
                    a[j-1]=t;
                }
            }
        }
        for(i=1;i<=N;i++)
        {
            if(i%2==1)
                sum+=a[i];
            else
                sum-=a[i];
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
from heapq import heapify, heappop, heappush

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

for i in range(n):
    a[i] *= -1
heapify(a)
#print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, -(-maxa//2))
#print(a)
print(-(sum(a)))

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

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	int n , k  , sum = 0 ;
	cin >> n >> k ;
	int cnt[n] ; 
	for(int i = 0 ; i < n ; ++i)
	{
		cin >> cnt[i] ; 
	}  
	sort(cnt , cnt + n) ; 
	for(int i = 0 ; i < k ; ++i)
	{
		sum += cnt[i] ;  
	}
	cout << sum ;
}



Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F solver = new F();
        solver.solve(1, in, out);
        out.close();
    }

    static class F {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            int sl = s.length();
            int tl = t.length();
            int[][] dp = new int[sl + 1][tl + 1];
            for (int i = 0; i < sl; i++) {
                for (int j = 0; j < tl; j++) {
                    if (s.charAt(i) == t.charAt(j)) {
                        dp[i + 1][j + 1] = Math.max(dp[i][j + 1], Math.max(dp[i + 1][j], dp[i][j] + 1));
                    } else {
                        dp[i + 1][j + 1] = Math.max(dp[i][j + 1], Math.max(dp[i + 1][j], dp[i][j]));
                    }
                }
            }
            StringBuilder sb = new StringBuilder();
            while (sl > 0 && tl > 0 && dp[sl][tl] > 0) {
                while (dp[sl - 1][tl] == dp[sl][tl]) sl--;
                while (dp[sl][tl - 1] == dp[sl][tl]) tl--;
                sb.append(s.charAt(sl - 1));
                sl--;
                tl--;
            }
            out.println(sb.reverse().toString());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 82868
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };


    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [(i32, i32); n],
        b: [(i32, i32); n],
    }
    let mut a = a;
    let mut b = b;
    a.sort();
    b.sort();

    let mut used = vec![false; n];
    for (x, y) in b {
        let mut max_y = -1;
        let mut j = 0;
        for (i, a) in a.iter().take_while(|a| a.0 < x).enumerate() {
            if !used[i] && a.1 < y && a.1 > max_y {
                max_y = a.1;
                j = i;
            }
        }
        if max_y >= 0 {
            used[j] = true;
        }
    }
    println!("{}", used.iter().filter(|&&u| u).count());
}


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

using namespace std;
int a[101];
int n,k;
int f[100005];
int main()
{
    //memset(f,-1,sizeof(f));
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
  for(int i=0;i<=k;i++)
    for(int j=0;j<n;j++)
    {
        if(i>=a[j]) f[i]=max(f[i],1-f[i-a[j]]);
    }
   // cerr<<f[1]<<endl;
    if(f[k]==1) cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,k,dd;
  cin>>n>>k;
  vector<int> d(10,0);
  for(int i=0;i<k;i++){
    cin>>dd;
    d[dd]=1;
  }
  for(int i=n;i<100000;i++){
    int flag=1;
    int tmp=i;
    while(tmp!=0){
       if(d[tmp%10]==1){
         flag=0;
         break;
       }
      tmp/=10;
    }
    if(flag){
      cout<<i<<endl;
       break;
    }
  }
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long int cnt,s;
    cnt=1,s=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]<=s)
        {
            cnt++;
            s=a[i];
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 5200
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String  out = "";
    String[] rs = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
    while (scanner.hasNext()) {
      double f = scanner.nextDouble();
      double t = scanner.nextDouble();
      int fr = 7;
      int tr = 7;
      if (f < 35.5) {
        fr = 0;
      } else if (f < 37.5) {
        fr = 1;
      } else if (f < 40) {
        fr = 2;
      } else if (f < 43) {
        fr = 3;
      } else if (f < 50) {
        fr = 4;
      } else if (f < 55) {
        fr = 5;
      } else if (f < 70) {
        fr = 6;
      } else {
        fr = 7;
      }
      if (t < 60+11) {
        tr = 0;
      } else if (t < 60+17) {
        tr = 1;
      } else if (t < 60+23) {
        tr = 2;
      } else if (t < 60+29) {
        tr = 3;
      } else if (t < 60+45) {
        tr = 4;
      } else if (t < 60+56) {
        tr = 5;
      } else if (t < 60+60+28) {
        tr = 6;
      } else {
        tr = 7;
      }
      if (fr < tr) {
        out += rs[tr] + "\n";
      } else {
        out += rs[fr] + "\n";
      }
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 20544
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

typedef std::pair<int, int> P;

int main() {

  bool isprime[(int)1e6];

  isprime[0] = isprime[1] = false;
  for(int i = 2; i < 1e6; ++i) {
    isprime[i] = true;
  }
  for(int i = 2; i < 1e3; ++i) {
    if( isprime[i] ) {
      for(int j = i + i; j < 1e6; j += i) {
        isprime[j] = false;
      }
    }
  }
  
  for(;;) {
    int a, d, n;
    std::cin >> a >> d >> n;
    if( a == 0 and d == 0 and n == 0 ) break;

    int count = 0;
    int x = a;
    for(;;) {
      if( isprime[x] ) count += 1;
      if( count == n ) {
        std::cout << x << std::endl;
        break;
      }
      x += d;
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;


int main()
{
    ll n;cin >> n;
    string ans = "";
    while(n >= 1)
    {
        int p = n % 26;
        if(!p)p = 26;
        n -= p;
        n /= 26;
        ans += 'a'+p-1;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;

    return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**9)

def dfs(v,mod):
  cnt=0
  ret=1
  for i in g[v]:
    if checked[i]==0:
      checked[i]=1
      cnt+=1
      ret=(ret*dfs(i,mod))%mod
  for i in range(cnt):
    ret=(ret*(k-2-i))%mod
  return ret
  
n,k=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
mod=10**9+7
checked=[0]*(n+1)
checked[1]=1
ans=k
for i in range(len(g[1])):
  ans=(ans*(k-1-i))%mod
for i in g[1]:
  checked[i]=1
  ans=(ans*dfs(i,mod))%mod
print(ans)

Measured memory_bytes: 88112
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, M = sc.nextInt()
    val ABs = Array.fill(N, 2)(sc.nextLong())
    val s = ABs.sortBy(_.head)
    println(s.foldLeft((0L, M.toLong)) {
      case ((acc, m), arr) if m == 0 =>
        (acc, 0)
      case ((acc, m), arr) =>
        val a = arr.head
        val b = arr.last
        val buy = Math.min(m, b)
        (acc + (a * buy), m - buy)
    }._1)
  }
}


Measured memory_bytes: 108160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
ll n,W,i,w[109],v[109],a[100009],j,ans=0;
int main() {
    cin>>n>>W;
    for(i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    for(i=0;i<100009;i++)
        a[i] = 100000000000009;
    a[0] = 0;
    for(i=0;i<n;i++){
        for(j=100009;j>=0;j--){
            if(j - v[i] >=0){
                a[j] = minn(a[j] ,w[i] + a[j - v[i]]);
            }
        }
    }
    for(i=0;i<100009;i++){
        if(a[i]<=W){
            ans = i;
            // cout<<i<<" ";
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace atcoder;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, m;
    std::cin >> n >> m;
    
    std::vector<std::string> s(n);
    for (int i = 0; i < n; ++i)
        std::cin >> s[i];
    
    mcf_graph<int, int> g(n * m + 2);
    
    const int S = n * m, T = S + 1;
    
    int ans = 0;
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '#')
                continue;
            if (s[i][j] == 'o') {
                g.add_edge(S, i * m + j, 1, 0);
                ans += n + m - i - j;
            }
            g.add_edge(i * m + j, T, 1, n + m - i - j);
            if (j < m - 1 && s[i][j + 1] != '#')
                g.add_edge(i * m + j, i * m + j + 1, 100, 0);
            if (i < n - 1 && s[i + 1][j] != '#')
                g.add_edge(i * m + j, (i + 1) * m + j, 100, 0);
        }
    }
    
    ans -= g.flow(S, T).second;
    
    std::cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 4180
//============================================================================
// Name        : tokuteigai.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

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



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

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> hp(n);
    rep(i,n){
        cin >> hp.at(i);
    }
    sort(hp.begin(),hp.end());
    reverse(hp.begin(),hp.end());

    rep(i,min(k,n)){
        hp.at(i)=0;
    }

    ll sum=0;
    rep(i,n){
        sum+=hp.at(i);
    }

    cout << sum << endl;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int b[26]={0};
	while(cin>>s){
		for(int i=0;i<s.size();i++){
			if(s[i]>='A'&s[i]<='Z'){
				b[s[i]-'a'+32]++;
			}else
				b[s[i]-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		cout<<char('a'+i)<<" : "<<b[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3184
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    a=LIST()
    count = 1
    breakb = 0
    for i in range(n):
        if a[i]==count:
            count+=1
        else:
            breakb += 1
    if count==1:
        print(-1)
    else:
        print(breakb)
    
            
if __name__ == '__main__':
    do()

Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,i,j;
  cin>>n>>m;
  
  int k[n],kind[m]={},ans=0;
  
  for(i=0;i<n;i++){
    cin>>k[i];
    int a[k[i]];
    for(j=0;j<k[i];j++){
      cin>>a[j];
      kind[a[j]-1]++;
    }
  }
  
  for(i=0;i<m;i++){
    if(kind[i]==n)
      ans++;
    cerr<<kind[i];
    
  }
  cout<<ans;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> a[10];
  vector<char> ans;
  a[0].push_back('.');
  a[0].push_back(',');
  a[0].push_back('!');
  a[0].push_back('?');
  a[0].push_back(' ');
  a[1].push_back('a');
  a[1].push_back('b');
  a[1].push_back('c');
  a[2].push_back('d');
  a[2].push_back('e');
  a[2].push_back('f');
  a[3].push_back('g');
  a[3].push_back('h');
  a[3].push_back('i');
  a[4].push_back('j');
  a[4].push_back('k');
  a[4].push_back('l');
  a[5].push_back('m');
  a[5].push_back('n');
  a[5].push_back('o');
  a[6].push_back('p');
  a[6].push_back('q');
  a[6].push_back('r');
  a[6].push_back('s');
  a[7].push_back('t');
  a[7].push_back('u');
  a[7].push_back('v');
  a[8].push_back('w');
  a[8].push_back('x');
  a[8].push_back('y');
  a[8].push_back('z');
  char x;
  int n;
  cin>>n;
  
  scanf("%c",&x);
  int memo=-1,count=-1,z=0;
  for(int i=0;i<n;i++){
    while(1){
      scanf("%c",&x);
      if('0'<=x &&x<='9'){
	z=x-'0';
	if(z!=0){
	  memo=z;
	  count++;
	}
	else{
	  memo--;
	  if(memo==-2){
	    memo=-1;
	    continue;
	  }
	  count%=a[memo].size();
	  cout<<a[memo][count];
	  memo=-1;
	  count=-1;
	}
      }
      else{
	cout<<endl;
      break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3224
h,w=map(int,input().split())
z=[0]*(w+1)
for i in range(h):
    a=list(map(int,input().split()))
    a.append(sum(a))
    for y in range(w+1):
      z[y]+=a[y]
    x=''
    for j in a:
        x+=str(j)
        x+=' '
    x=x[:-1]
    print(x)
t=''
for s in z:
        t+=str(s)
        t+=' '
t=t[:-1]
print(t)


Measured memory_bytes: 5616
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for i := len(a) - 1; i >= 0; i-- {
		if i < len(a)-1 {
			fmt.Print(" ")
		}
		fmt.Print(a[i])
	}
	fmt.Println()
}




Measured memory_bytes: 1128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;



int h, w;
string s[50];
map<char, int> x, X, y, Y;
map<char, int> d[65][65];

int count(int sx, int sy, int ex, int ey, char c){
	return d[ey][ex][c] - d[sy][ex][c] - d[ey][sx][c] + d[sy][sx][c]; 
}

bool calc(vector<char> &v){
	int n = v.size();
	for(int i = 0; i < n; i++){
		char c = v[i];
		if(count(x[c], y[c], X[c] + 1, Y[c] + 1, '.') > 0) return false;
		for(int j = 0; j < i; j++){
			if(count(x[c], y[c], X[c] + 1, Y[c] + 1, v[j]) > 0) return false;
		}
	}
	return true;
}

int main(){
	int n = in.nextInt();
	while(n--){
		h = in.nextInt(); w = in.nextInt();
		rep(i, h) s[i] = in.next();
		x.clear(); X.clear(); y.clear(); Y.clear();
		rep(i, h + 1) rep(j, w + 1) d[i][j].clear();

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(x.find(s[i][j]) == x.end()){
					x[s[i][j]] = X[s[i][j]] = j;
					y[s[i][j]] = Y[s[i][j]] = i;					
				}
				else{
					x[s[i][j]] = min(x[s[i][j]], j);
					X[s[i][j]] = max(X[s[i][j]], j);

					y[s[i][j]] = min(y[s[i][j]], i);
					Y[s[i][j]] = max(Y[s[i][j]], i);
				}
			}
		}

		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				for(auto p : x){
					d[i][j][p.fi] += d[i-1][j][p.fi];
					if(p.fi == s[i-1][j-1]) d[i][j][p.fi]++;
				}
			}
		}

		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				for(auto p : x){
					d[i][j][p.fi] += d[i][j-1][p.fi];
				}
			}
		}
		vector<char> v;
		for(auto p : x) if(p.fi != '.') v.pb(p.fi);


		bool f = false;
		do{
			f |= calc(v);
			// if(calc(v)){
			// 	for(int i = 0; i < v.size(); i++)cout<<" "<<v[i];
			// 	cout<<endl;
			// }
		}while(next_permutation(all(v)));

		printf("%s\n", (f?"SAFE":"SUSPICIOUS"));
	}
}

Measured memory_bytes: 4428
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const long double eps = 0.0000000001;
std::vector<long double>x(3), y(3), edge(3);
long double r1, r2;

long double triangleS(long double px1, long double py1, long double px2, long double py2, long double px3, long double py3)
{
	return abs((px1 - px3)*(py2 - py3) - (px2 - px3)*(py1 - py3)) / 2.;
}

bool check(long double x)
{
	r2 = r1 - x;
	auto ll = edge[2] * r2 / r1;
	return ll >= x * 2;
}

int main()
{
	rep(i, 3) in >> x[i] >> y[i];
	rep(i, 3) edge[i] = sqrt((x[i] - x[(i + 1) % 3])*(x[i] - x[(i + 1) % 3]) + (y[i] - y[(i + 1) % 3])*(y[i] - y[(i + 1) % 3]));
	std::sort(edge.begin(), edge.end());
	r1 = 2. * triangleS(x[0], y[0], x[1], y[1], x[2], y[2]) / (edge[0] + edge[1] + edge[2]);
	long double l = 0., r = 114514.;
	while (r - l > eps)
	{
		auto m = (r + l) / 2;
		if (check(m)) l = m;
		else r = m;
	}
	out << std::fixed << std::setprecision(12);
	out << l << std::endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  long long sum = 0;
  for (int i = 0; i < n - 1; i++){
    if (a[i + 1] > a[i]){
      sum += a[i + 1] - a[i];
    } else {
      sum += m - (a[i] - a[i + 1]);
    }
  }
  vector<int> A(m + 1, 0);
  vector<long long> B(m + 1, 0);
  for (int i = 0; i < n - 1; i++){
    if (a[i + 1] > a[i]){
      A[a[i] + 1]++;
      A[a[i + 1] + 1]--;
      B[a[i] + 1] -= a[i] + 1;
      B[a[i + 1] + 1] += a[i] + 1;
    } else {
      A[a[i] + 1]++;
      A[m]--;
      B[a[i] + 1] -= a[i] + 1;
      B[m] += a[i] + 1;
      A[0]++;
      A[a[i + 1] + 1]--;
      B[0] += m - a[i] - 1;
      B[a[i + 1] + 1] -= m - a[i] - 1;
    }
  }
  for (int i = 1; i <= m; i++){
    A[i] += A[i - 1];
    B[i] += B[i - 1];
  }
  vector<long long> C(m);
  for (int i = 0; i < m; i++){
    C[i] = (long long) A[i] * i + B[i];
  }
  long long mx = 0;
  for (int i = 0; i < m; i++){
    mx = max(mx, C[i]);
  }
  cout << sum - mx << endl;
}

Measured memory_bytes: 5512
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
using namespace std;
int main(){
	ll n, ans=0;
	cin>>n;
	vector<ll>A(n);
	for(ll&a:A){
		cin>>a;
	}
	sort(A.rbegin(), A.rend());
	vector<ll>oo={A[0]};
	ll j=0;
	for(ll i=1; i<n; i++){
		ans+=oo[j];
		j++;
		oo.push_back(A[i]);
		oo.push_back(A[i]);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 9024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int N, a, b, ans, s, t;
  cin >> N;
  vector<int> A, B;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ans = 0;
  vector<int>::iterator itr1, itr2;
  for (int i = N + 1; i > 0; --i) {
    itr1 = lower_bound(A.begin(),A.end(),i+1);
    itr2 = lower_bound(B.begin(),B.end(),i);
    s = distance(A.begin(), itr1);
    t = distance(B.begin(), itr2);
    if (s-t >= i-1) {
      ans = i-1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

string s;

int main(){
	cin>>s;
	int ans=(int)s.size();
	REP(i,(int)s.size()){
		char c=s[i];
		int cnt=0,temp=0;
		REP(j,(int)s.size()){
			if (s[s.size()-j-1]!=c){
				cnt++;
			}else{
				cnt=0;
			}
			temp=max(temp,cnt);
		}
		ans=min(ans,temp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0];b=[0];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47496
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    int sum=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if (z>=0 && z<=k){
                sum++;}
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define af(i,a,b) for( int i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long double ld;
typedef long long int ll;
typedef vector<int> vi ;
typedef pair<int,int> ii ;
typedef vector<ii> vii ;

const int MAX= 1001;
ll c[110], mod=1e9 +7, dp[110][100010];
int main(){
	fastio;
	int n,m,k;
	cin>>n>>k;
	f(i,0,n) cin>>c[i];
	f(i,0,n+1) dp[i][0]=1LL;
	f(i,0,c[0]) dp[0][i+1]=1LL;
	f(i,1,n){
		ll sum=dp[i-1][0];		
		f(j,1,k+1){
			sum+=dp[i-1][j];
			if(j>c[i]) sum-=dp[i-1][j-c[i]-1];
			sum=(sum+mod)%mod;
			dp[i][j]=sum;
		}
	}
	cout<<dp[n-1][k];
}	


Measured memory_bytes: 80128
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;
int main(){
  int n;
  cin>>n;
  int c1[40],c2[40];
  fill(c1,c1+40,10000);
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    fill(c2,c2+40,0);
    for(int j=0;j<s.size();j++){
      c2[(int)s[j]-97]++;
    }
    for(int j=0;j<40;j++){
      c1[j]=min(c1[j],c2[j]);
    }
  }
  for(int i=0;i<40;i++){
    for(int j=0;j<c1[i];j++){
      cout<<(char)(i+97);
    }
  }
  cout<<endl;
  return 0;
}


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int h,w;
    cin >> h >> w;

    vector<vector<char>> a(h, vector<char>(w, 0));
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            cin >> a.at(ih).at(iw);
        }
    }

    vector<int> hskip;
    vector<int> wskip;
    bool flg;
    for(int ih=0;ih<h;ih++) {
        flg = true;
        for(int iw=0;iw<w;iw++) {
            if(a.at(ih).at(iw)=='#') { 
                flg = false;
                break;
            }
        }
        if(flg) hskip.push_back(ih);
    }
    for(int iw=0;iw<w;iw++) {
        flg = true;
        for(int ih=0;ih<h;ih++) {
            if(a.at(ih).at(iw)=='#') { 
                flg = false;
                break;
            }
        }
        if(flg) wskip.push_back(iw);
    }

    bool flgrt;
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            flg = true;
            flgrt = true;
            for(auto jh:hskip) {
                if(ih==jh) { 
                    flg=false;
                    flgrt = false;
                }
            }
            for(auto jw:wskip) {
                if(iw==jw) flg=false;
            }
            if(flg) cout << a.at(ih).at(iw);
        }
        if(flgrt) cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    ll arr[n];
    vector<ll> a;
    for(i=0;i<n;i++){
        cin>>arr[i];
        a.push_back(arr[i]);
    }
    sort(a.rbegin(),a.rend());
    for(i=0;i<n;i++){
        if(arr[i]==a[0])
            cout<<a[1]<<endl;
        else
            cout<<a[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 int main()
  {
     int n,m;
    cin>>n>>m;
     if(n==1)
     {
         n=14;
     }
    if(m==1)
    {
        m=14;
     }
   if(n==m)
     {
       cout<<"Draw";
    }
    else if(n<m)
     {          cout<<"Bob";
     }
     else
     {
        cout<<"Alice";
    }
    return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    vector<double> a(N), rec(N);
    rep(i,0,N) cin >> a[i];
    double ans = 0.0;
    rep(i,0,N) {
        double temp = a[i];
        rep(j,0,i) {
            chmax(temp, rec[j] + 2 * sqrt(a[i] * a[j]));
        }
        rec[i] = temp;
        chmax(ans, rec[i] + a[i]);
    }
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 3292
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let h = cin.next_usize();
    let w = cin.next_usize();
    let mut map = vec![vec![0; w + 2]; h + 2];
    let mut ans = vec![vec![' '; w]; h];
    for y in 0..h {
        let s = cin.next();
        let s = s.as_bytes();
        for x in 0..w {
            map[y+1][x+1] = if s[x] == ('#' as u8) { 1 } else { 0 };
        }
    }
    for y in 0..h {
        for x in 0..w {
            ans[y][x] = if map[y+1][x+1] == 1 {
                '#'
            } else {
                let mut cnt = 0_u8;
                for dy in 0..3 {
                    for dx in 0..3 {
                        cnt += map[y+dy][x+dx];
                    }
                }
                (cnt + '0' as u8) as char
            }
        }
    }
    for y in 0..h {
        for x in 0..w {
            print!("{}", ans[y][x]);
        }
        println!("");
    }
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int main()
{
	int k,i,c,len,a1;
	char s[101],a[101];
	scanf("%d %s",&k,s);
	len=strlen(s);
	c=0;
	for(i=0;i<len;i++){
		c++;
	}
	a1=0;
	a1=c-k;
	c=c-a1;
	if(a1>0){
		for(i=0;i<c;i++){
			printf("%c",s[i]);
		}
		printf("...\n");
	}
	else	printf("%s\n",s);
	return 0;
}


Measured memory_bytes: 1620
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<pair<int, int> > vec(n);
  rep(i,n) scanf("%d %d", &(vec[i].fi), &(vec[i].se));
  rep(i,n){vec[i].fi--; vec[i].se--;}

  set<pair<int, int> > m;
  rep(i,n) m.insert(vec[i]);

  vector<long> res(10,0);

  const int d[]={-1,0,1};
  rep(i,n){
    rep(j,3) rep(k,3){ //offset
      int cnt=0;
      rep(xx,3) rep(yy,3){ //diff
        int nx = vec[i].fi+d[j]+d[xx];
        int ny = vec[i].se+d[k]+d[yy];
        if(nx<0 || ny<0 || nx>=h || ny>=w){
          cnt=-1;
          xx=3;yy=3;
        }
        else if(m.find(mp(nx,ny))!=m.end()) cnt++;
      }
      if(cnt>0) res[cnt]++;
    }
  }

  res[0]=(long)(h-2)*(w-2);
  repl(i,1,10){
    res[i]=res[i]/i;
    res[0]-=res[i];
  }

  rep(i,10) printf("%ld\n", res[i]);

  return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>

int n,cou = 0,i;
char a[100] = {0},b[100] = {0},c[100] = {0};

int main()
{
    scanf("%s",a);
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
        scanf("%s",b);
        strncat(b,b,10);
        if(strstr(b,a) != NULL)cou++;
    }
    printf("%d\n",cou);
    return 0;
}

Measured memory_bytes: 1044