akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
s = [input() for i in range(h)]

yoko = [[0] * w for i in range(h)]
for i in range(h):
    tmp = 0
    l = 0
    for j in range(w + 1):
        if j == w or s[i][j] == "#":
            for k in range(l, j):
                yoko[i][k] = tmp
            l = j + 1
            tmp = 0
        else:
            tmp += 1
            
tate = [[0] * w for i in range(h)]
for j in range(w):
    tmp = 0
    l = 0
    for i in range(h + 1):
        if i == h or s[i][j] == "#":
            for k in range(l, i):
                tate[k][j] = tmp
            l = i + 1
            tmp = 0
        else:
            tmp += 1

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, tate[i][j] + yoko[i][j])
print(ans - 1)

Measured memory_bytes: 130648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  string S;
  cin >> S;

  vector<int64_t> d(S.size() + 1, 0);
  N_TIMES(n, S.size()) { d[n + 1] = d[n] + ((S[n] == '(') ? +1 : -1); }

  int64_t min_d = *min_element(d.begin(), d.end());
  string left(-min_d, '(');
  string right(d[S.size()] - min_d, ')');

  string T = left + S + right;
  cout << T << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

from collections import defaultdict
d = defaultdict(list)

for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = [int(x) for x in input().split()]
        d[i].append((x - 1, y))
ans = 0
for k in range(2**n):
    res = 0
    j = bin(k)[2:].zfill(n)
    flag = 1
    for i in range(n):
        if j[i] == "0":
            continue
        for x, y in d[i]:
            if int(j[x]) != int(y):
                flag = 0
                break
        res += 1
    if flag:
        ans = max(ans, res)
print(ans)

Measured memory_bytes: 45532
def main():
  N, K = (int(x) for x in input().split())
  ret = 0
  for d in range(1, N + 1):
    cc = 0
    d = (K-1)//d
    while d > 0:
      d //= 2
      cc += 1
    ret += 1 / (N * pow(2, cc))
  print(ret)
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
k = int(input())
import math
ans = 0
for i in range(1,k+1):
         for j in range(i,k+1):
                  for l in range(j,k+1):
                           tmp = math.gcd(i,j)
                           tmp = math.gcd(tmp,l)
                           if i == j == l:
                                    ans += tmp
                           elif i == j or j == l or l == i:
                                    ans += 3 * tmp
                           else:
                                    ans += 6 * tmp
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  bool ok = false;
  cin >> n;
  rep (i, 0, (n/7)+1 ) {
    if ( (n-7*i) % 4 == 0) {
      ok = true;
      break;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

ll solve(vector<int> &weight, vector<int> &value, int w) {
  int n = value.size();
  vector<vector<ll>> dp(w + 1, vector<ll>(n + 1, 0));
  for(int wt = 1; wt <= w; ++wt) {
    for(int j = 1; j <= n; ++j) {
      if(wt - weight[j-1] >= 0) {
        dp[wt][j] =
            max(dp[wt][j], value[j - 1] + dp[wt - weight[j - 1]][j - 1]);
        dp[wt][j] = max(dp[wt][j], dp[wt][j-1]);
      } else {
        dp[wt][j] = dp[wt][j - 1];
      }
    }
  }
  return dp[w][n];
}

int main() {
  int n, w;
  cin >> n >> w;
  vector<int> value(n, 0);
  vector<int> weight(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> weight[i];
    cin >> value[i];
  }
  cout << solve(weight, value, w) << '\n';
  return 0;
}



Measured memory_bytes: 85280
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(),x.end())
#include<math.h>
#include<vector>
#include<iostream>
#include<istream>
#include<string.h>
using namespace std;

int main()
{
    int a,b,temp=1;
    cin>>a>>b;
    if(b==1)
    {
        printf("0\n");
        return 0;
    }
    if(b<a)
    {
        temp=0;
    }
    if(temp==0)
    {
        printf("1\n");
    }
    else
    {
        b-=a;
        int counter=1;
        while(b>0)
        {
            counter++;
            b-=(a-1);
        }

        printf("%d\n",counter);
    }



    return 0;
}


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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	string S, T; cin >> S >> T;
	vector<int> X(S.size()+1);
	vector<int> Y(T.size()+1);
	for (int i = 0; i < int(S.size()); i++) X[i+1] = (X[i] + (S[i] - 'A' + 1)) % 3;
	for (int i = 0; i < int(T.size()); i++) Y[i+1] = (Y[i] + (T[i] - 'A' + 1)) % 3;

	int Q; cin >> Q;
	while (Q--) {
		int a, b, c, d; cin >> a >> b >> c >> d; a--, c--;
		cout << ((X[b] - X[a] - Y[d] + Y[c]) % 3 == 0 ? "YES" : "NO") << '\n';
	}

	return 0;
}


Measured memory_bytes: 1744
import collections
h,w = map(int,input().split())
c = []
wall = []


def judge(num):
    koho = collections.deque()
    for i in range(10):
        if dp[i] > dp[num] + c[i][num]:
            koho.append(i)
            dp[i] = dp[num] + c[i][num]
    if koho:
        here = koho.popleft()
        judge(here)



for i in range(10):
    c.append(list(map(int,input().split())))
for i in range(h):
    wall.extend(list(map(int,input().split())))
wall = collections.Counter(wall)
dp = [0] * 10
for i in range(10):
    dp[i] = c[i][1]
for i in range(10):
    judge(i)
ans = 0
wall = list(wall.items())
for i in range(len(wall)):
    if wall[i][0] == -1:
        pass
    else:
        ans += dp[wall[i][0]] * wall[i][1]
print(ans)





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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
if(a*b<=c) {
	System.out.println(a*b);
}
else {
	System.out.println(c);
}
	}

}


Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
#include<utility>
using namespace std;

const int N = 100;
pair<int,int> a[N+2];
pair<int,int> b[N+2];
bool f[N+2][N+2];
bool used[N+2];
int match[N+2];
int n,m;

bool DFS(int pos)
{
	for(int i=1; i<=m; i++)
	{
		if(f[pos][i] && !used[i])
		{
			used[i] = true;
			if(!match[i] || DFS(match[i]))
			{
				match[i] = pos;
				return true;
			}
		}
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d%d",&a[i].first,&a[i].second);
	for(int i=1; i<=n; i++) scanf("%d%d",&b[i].first,&b[i].second);
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(a[i].first<b[j].first && a[i].second<b[j].second) f[i][j] = true;
		}
	}
	m = n; int ans = 0;
	for(int i=1; i<=n; i++)
	{
		memset(used,false,sizeof(used));
		if(DFS(i)) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import copy
def BubbleSort(n, A):
    cnt = 0
    flg = True
    while flg:
        flg = False
        for j in range(n-1, 0, -1):
            if int(A[j][1:2]) < int(A[j-1][1:2]):
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                cnt += 1
                flg = True
    
def SelectionSort(n, B):
    cnt = 0
    for i in range(n):
        minj = i
        for j in range(i+1, n):
            if int(B[j][1:2]) < int(B[minj][1:2]):
                minj = j
        if minj != i:
            tmp = B[i]
            B[i] = B[minj]
            B[minj] = tmp
            cnt += 1
    
def IsStable(A, B):
    for a1 in A:
        for b1 in B:
            if int(a1[1:2]) == int(b1[1:2]):
                if a1 == b1:
                    B.remove(b1)
                    break
                else:
                    return "Not stable"
            elif int(a1[1:2]) < int(b1[1:2]):
                break
    return "Stable"
    
n = int(input())
C = input().split()
A = copy.deepcopy(C)
B = copy.deepcopy(C)

BubbleSort(n, A)
print(" ".join(A))
print(IsStable(C, A))

SelectionSort(n, B)
print(" ".join(B))
print(IsStable(C, B))


Measured memory_bytes: 6344
#include <stdio.h>

int keta(int x)
{
  int i = 0;
  while ( x > 0 ) {
    x /= 10;
    i++;
  }

  return i;
}

int main(void)
{
  int a, b;
  while ( scanf("%d %d", &a, &b) != EOF ) {
    printf("%d\n", keta(a+b));
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish{
    ll time;
    ll taste;
};
int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;

    auto F = [] (string s) {
        set<char> cnt;
        for (auto &&e : s)
        {
            cnt.insert(e);
        }
        return cnt;
    };

    ll ans = 0;
    set<char> st = F(S);

    for (ll i = 1; i < N; i++)
    {
        string s1 = S.substr(0, i);
        string s2 = S.substr(i);

        set<char> set1 = F(s1);
        set<char> set2 = F(s2);

        ll cnt = 0;
        for (auto &&e : st)
        {
            if (set1.count(e) > 0 && set2.count(e) > 0) {
                cnt += 1;
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int k, n;
    IN(k, n);

    ll x = 1;
    int ans = 0;
    while(x <= k){
        ans++;
        x *= n;
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int h, w;
    while (true)
    {
        cin >> h >> w;
        if (h + w == 0)
        {
            break;
        }

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if ((j != 0 && j != w - 1) && (i != 0 && i != h - 1))
                {
                    cout << '.';
                }
                else
                {
                    cout << '#';
                }
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int v[n],c[n];
  int ans=0;
  REP(i,n){
    cin>>v[i];
  }
  REP(i,n){
    cin>>c[i];
  }
  REP(i,n){
    if(v[i]-c[i]>0){
      ans += v[i]-c[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{
     int W, H, x, y, r;
     scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(((x + r <= W) && (x - r >= 0)) && ((y + r <= H) && (y - r >= 0))){
    printf("Yes\n");
    }
    else {
        printf("No\n");
    }
     return 0;
 }

Measured memory_bytes: 580
#include <stdio.h>

int main(void)
{
    long h;
    long n = 1;
    long c = 0;
    scanf("%ld",&h);
    
    do{
        if (h == 1){
            c = c+n;
        }
        else {
            c = c+n;
            n = 2*n;
        }
        h = h/2;
    } while (h >= 1);
    
    printf("%ld\n",c);
    return 0;
}


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

int main () {
    int N;

    cin >> N;
    vector<int> a(N, 0);
    int count_4 = 0;
    int count_2 = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];

        if(a[i] % 4 == 0) count_4++;
        else if(a[i] % 2 == 0) count_2++;
    }

    if(2*count_4 >= N-1) cout << "Yes" << endl;
    else if(2*count_4 + (count_2-1) >= N-1 ) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 640
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import copy

def main():
    mod=10**9+7
    N,M=MI()
    inf=1000
    D=[[inf]*N for _ in range(N)]
    for _ in range(M):
        a,b=MI()
        a-=1
        b-=1
        D[a][b]=1
        D[b][a]=1
        
    for i in range(N):
        D[i][i]=0
        
    def warshall_floyd(d):
        #d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
           
        for i in range(N):
            for j in range(N):
                if d[i][j]==inf:
                    return True
        return False
    cnt=0 
    for i in range(N):
        for j in range(i,N):
            if D[i][j]==1:
                d=copy.deepcopy(D)
                d[i][j]=inf
                d[j][i]=inf
                if warshall_floyd(d):
                    cnt+=1
                    
    print(cnt)
    
    



main()


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define MOD 1000000007
#define endl "\n"

bool isPrime(int n)
{
    if(n<2)
        return 0;
    if(n<4)
        return 1;
    if(n%2==0 || n%3==0)
        return 0;
    for(int i=5;i*i<=n;i+=6)
    {
        if(n%i==0 || n%(i+2)==0)
            return 0;
    }
    return 1;
}

int main()
{
    IOS;
    int n;
    cin >>n;
    while(true)
    {
        if(isPrime(n))
        {
            cout <<n<<endl;
            break;
        }
        n++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, K;
    cin >> N >> K;
    int res = 0;
    rep(i, N) {
        int h;
        cin >> h;
        if(h >= K) res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int n, t, a, h;
int idx;
double g, mini=1000000;

int main(){
    scanf("%d %d %d", &n, &t, &a);
    for(int i=0; i<n; i++){
        scanf("%d", &h);
        g = t-h*0.006;//printf("%lf\n", g);
        double dif = a-g;
        if(dif < 0) dif*=(-1);
        //printf("%lf\n", dif);
        if(dif < mini){
            mini = dif;
            idx = i+1;
        }
    }
    printf("%d\n", idx);
}


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

int main()
{
	int a,c,d,sum=0;
    
    cin>>a>>c;
    c--;
    string s;
	
    for(int i=0;i<a;i++ )
    {
        cin>>s[i];

    }
    if(s[c] =='A')
        s[c] ='a';
    else if(s[c] == 'B')
        s[c]='b';
    else
    {
        s[c]='c';
    }
    for(int i=0;i<a;i++)
        cout<<s[i];
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
vector<long long> A;
int main() {
	cin >> N;
	A.resize(N);
	for (auto& x : A) cin >> x;
	long long r = 0;
	long long q = 0;
	for (auto x : A) {
		r += (x + q) / 2;
		q = (x + q) % 2;
		if (x == 0) q = 0;
	}
	cout << r << endl;
}


Measured memory_bytes: 1024
h,w,c,max;
int *_M;
int D(x,y,c,n){
	int r=1;
	_M[x+(w+2)*y]=n;
	if(_M[x-1+(w+2)*y]==c)r+=D(x-1,y,c,n);
	if(_M[x+1+(w+2)*y]==c)r+=D(x+1,y,c,n);
	if(_M[x+(w+2)*(y-1)]==c)r+=D(x,y-1,c,n);
	if(_M[x+(w+2)*(y+1)]==c)r+=D(x,y+1,c,n);
	return r;
}
E(d,M)int *M;{
	if(d==4&&M[1+w+2]==c)return;
	int *m=malloc(400);
	if(d==4){
		memcpy(m,M,400);_M=m;
		D(1,1,m[1+w+2],c);
		int k=D(1,1,m[1+w+2],-1,m);
		if(max<k)max=k;
	}else{
		int i=1;
		for(;i<7;i++){
			if(M[1+w+2]==i)continue;
			memcpy(m,M,400);_M=m;
			D(1,1,m[1+w+2],i,m);
			E(d+1,m);
		}
	}
	free(m);
}
a[100];
main(i,j){for(;scanf("%d%d%d",&h,&w,&c),c;printf("%d\n",max)){
	memset(a,0,400);
	for(j=1;j<h+1;j++)for(i=1;i<w+1;i++)scanf("%d",a+i+(w+2)*j);
	E(max=0,a);
}}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

ll mul (ll x,ll y) {
	return ((x*y)%MOD+MOD)%MOD;
}

void solve () {
	int n,k;
	cin >> n >> k;
	vl arr(n);
	for (int i = 0;i < n;++i) {
		cin >> arr[i];
	}
	sort(all(arr));
	if (k == n) {
		ll prod = 1;
		for (int x : arr) {
			prod = mul(prod,x);
		}
		cout << prod << '\n';
		return;
	}
	bool hasPos = false;
	for (int x : arr) {
		if (x >= 0) {
			hasPos = true;
			break;
		}
	}
	if (!hasPos) {
		ll prod = 1;
		if (k%2 == 0) {
			for (int i = 0;i < k;++i) {
				prod = mul(prod,arr[i]);
			}
		} else {
			for (int i = 0;i < k;++i) {
				prod = mul(prod,arr[n-i-1]);
			}
		}
		cout << prod << '\n';
		return;
	}
	//we can make the ans positive
	int nNegs = 0;
	for (int x : arr) {
		if (x < 0) {
			++nNegs;
		} 
	}
	vl pos(n-nNegs),negs(nNegs);
	int pIdx = n-nNegs-1,nIdx = 0;
	for (int x : arr) {
		if (x < 0) {
			negs[nIdx++] = x;
		} else {
			pos[pIdx--] = x;
		}
	}
	vl prefPos((int)pos.size()+1),prefNeg((int)negs.size()+1);
	prefNeg[0] = prefPos[0] = 1;
	for (int i = 1;i <= pos.size();++i) {
		prefPos[i] = mul(pos[i-1],prefPos[i-1]);
	}
	for (int i = 1;i <= negs.size();++i) {
		prefNeg[i] = mul(negs[i-1],prefNeg[i-1]);
	}
	int nPos = min(k,(int)pos.size());
	int nNeg = k-nPos;
	if (nNeg&1) {
		nNeg++;
		nPos--;
	}
	while (nNeg+2 <= nNegs && nPos >= 2 && (ll)pos[nPos-1]*pos[nPos-2] < (ll)negs[nNeg]*negs[nNeg+1]) {
		nPos -= 2;
		nNeg += 2;
	}
	cout << mul(prefPos[nPos],prefNeg[nNeg]) << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  vector<int> last(26,0);

  auto calc_satisfaction_level = [&](int d,int i){
    int res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  vector<int> ans(d);

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

  auto test_all_get_max = [&](int di)->pair<int,int>{
    // 日付を引数にして全てのコンテストタイプを試してmaxscoreになるタイプを返す
    // 上位k個を返す
    int k = 5;
    int64_t val_max = -(1LL<<58),type_max = -1;
    vector<pair<int,int>> valtype_max(26);
    auto chmax = [](auto& a,auto b){if(a<b){a=b;return true;}return false;};
    for(int type=0;type<26;++type){
      if(chmax(val_max,calc_satisfaction_level(di,type)))type_max=type;
    }
    return {val_max,type_max};
  };

  for(int di=0;di<d;++di){
    auto [vi,type] = test_all_get_max(di);
    assert(type!=-1);
    ans[di] = type;
    last[type] = di+1;
  }

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

  for(auto x:ans){
    assert(1<=x+1 && x+1<=26);
    cout<< x+1 <<endl;
  }


}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

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

llint lcm(llint a, llint b)
{
	return a / gcd(a, b) * b;
}

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < seg.size(); i++) seg[i] = 1;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = lcm(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return 1;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return lcm(lval, rval);
	}
	llint query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

/*struct Rational
{
	llint a, llint b;
	Rational(){
		a = 0, b = 1;
	}
	Rational(llint x, llint y){
		a = x, b = y;
	}
	Rational operator+(const Rational& obj){
		llint bunbo = lcm(b, obj.b);
		llint bunsi1 = a * bunbo/b, bunsi2 = obj.a * bunbo/obj.b;
		return Rational( (bunsi1 + bunsi2) , bunbo );
	}
};*/

llint N, Q;
llint p[100005];
llint cycle[100005];
llint num[100005];
llint sum[100005];
llint accsum[100005];
SegTree seg(17);

void dfs(int v, int id)
{
	if(cycle[v]) return;
	cycle[v] = id;
	dfs(p[v], id);
}

int main(void)
{
	cin >> N >> Q;
	for(int i = 1; i <= N; i++) cin >> p[i];
	
	for(int i = 1; i <= N; i++){
		if(!cycle[i]) dfs(i, i);
	}
	for(int i = 1; i <= N; i++){
		num[cycle[i]]++;
	}
	for(int i = 1; i <= N; i++){
		sum[cycle[i]] += (i * pow(num[cycle[i]], mod-2)) % mod;
		sum[cycle[i]] %= mod;
	}
	for(int i = 1; i <= N; i++){
		accsum[i] = accsum[i-1] + sum[cycle[i]];
		accsum[i] %= mod;
	}
	seg.init();
	for(int i = 1; i <= N; i++) seg.update(i, num[cycle[i]]);
	
	llint l, r, ans;
	for(int q = 0; q < Q; q++){
		cin >> l >> r;
		ans = accsum[r] + (mod - accsum[l-1]);
		ans %= mod;
		ans *= seg.query(l, r) % mod;
		ans %= mod;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 8548
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long answer = 0;
			
			for(int i = 1; i <= N; i++) {
				if(i % 3 == 0) { continue; }
				if(i % 5 == 0) { continue; }
				
				answer += i;
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

ll l(int x)
{
	ll y=0;
	while(x)
	{
		y+=x%10;
		x/=10;
	}
	return y;
}

int main()
{
	ll n;
	cin >> n;
	ll ans=LONG_MAX;
	for(int i=1;i<=n-1;i++)
	{
		int j=n-i;
		ans=min(ans,l(i)+l(j));
	}		
	cout << ans;	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>

#include <iomanip>
#include <math.h>
#include<functional>
#include<assert.h>
#include<numeric>

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

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



struct Unionfind{
    vector<int> par;
    vector<int> rank;
    
    Unionfind(int n){
        init(n);
    }
    
    void init(int n){
        par.resize(n),rank.resize(n);
        rep(i,n) par[i]=i,rank[i]=0;
    }
    
   
   int find(int x){
       if (par[x]==x) return x;
       else return find(par[x]);
   }
    
    bool issame(int x,int y) {
        return find(x)==find(y);
    }
    
    bool merge(int x,int y) {
        x=find(x); y=find(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x, y);
        if (rank[x]==rank[y]) ++rank[x];
        par[y]=x;
        return true;
    }
    
};


int main(){
    int n,m;
    int x,y,z;
    cin>>n>>m;
    Unionfind uf(n);
    rep(i,m) {
        cin>>x>>y>>z;
        uf.merge(x-1,y-1);
    }
    int ans=0;
    rep(i,n)if(uf.find(i)==i)++ans;
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
struct threeElements{
int _1st,_2nd,_3rd;
};
int n,m;
int color[14],a[100009];
bool vis[100009];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   int ans=0,i=1;
   bool f=0;
   while(!vis[i])
   {
       ans++;
       if(a[i]==2)
        {
            f=1;
            break;
        }
       vis[i]=1;
       i=a[i];
   }
   if(f)
    cout<<ans;
   else
    cout<<-1;
}


Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a, b; cin >> a >> b;
    int n = b-a;

    int ans = (n*(n+1))/2  - b;
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
using System;
namespace AtCoder
{
	class Programs
	{
		static void Main ()
		{
			var nk = Array.ConvertAll (Console.ReadLine ().Split (), int.Parse);
			long ans = 0;
			int b = nk[0]/nk[1];
			ans += (long)Math.Pow(b,3);
			if(nk[1]%2==0)
			{
				b = (nk[0]+nk[1]/2)/nk[1];
				ans+=(long)Math.Pow(b,3);
			}
			Console.WriteLine (ans);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int H, W, N;
int a[10000 + 100];
int main() {
  cin >> H >> W >> N;
  for (int i = 0; i < N; ++i) cin >> a[i];
  int ind = 0;
  for (int row = 0; row < H; ++row) {
    vector<int> line;
    int col = 0;
    while (col < W) {
      if (a[ind] == 0) ind++;
      assert(a[ind] > 0);
      line.push_back(ind + 1);
      a[ind]--;
      col++;
    }
    if (row & 1) reverse(line.begin(), line.end());
    for(auto c: line) cout << c << ' ';
    cout << endl;
  }
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
    int n; ll k; cin>>n>>k;
    int a[200020];
    vector<int> ind[200020];
    for(int i=0; i<n; i++){
        cin>>a[i];
        ind[a[i]].push_back(i);
    }
    P nx[200020];
    for(int i=n-1; i>=0; i--){
        if(ind[a[i]].back()==i){
            nx[i]=P(1, ind[a[i]][0]+1);
            if(nx[i].second==n) nx[i]=P(2, 0);
        }else{
            int t=*upper_bound(ind[a[i]].begin(), ind[a[i]].end(), i);
            if(t+1<n) nx[i]=nx[t+1];
            else nx[i]=P(1, 0);
        }
    }
    P nxd[40][200020];
    for(int i=0; i<n; i++) nxd[0][i]=nx[i];
    for(int i=0; i<39; i++){
        for(int j=0; j<n; j++){
            nxd[i+1][j]=P(nxd[i][j].first+nxd[i][nxd[i][j].second].first, nxd[i][nxd[i][j].second].second);
        }
    }
    ll x1=0, x2=k+1;
    while(x2-x1>1){
        ll x=(x1+x2)/2;
        ll x0=x;
        ll c=0, p=0;
        int j=0;
        while(x0){
            if(x0&1ll){
                c+=nxd[j][p].first;
                p=nxd[j][p].second;
            }
            x0>>=1;
            j++;
        }
        if(c<=k-1) x1=x;
        else x2=x;
    }
    ll c=0, p=0;
    int j=0;
    while(x1){
            if(x1&1ll){
                c+=nxd[j][p].first;
                p=nxd[j][p].second;
            }
            x1>>=1;
            j++;
    }
    if(c<k-1){
        return 0;
    }
    vector<int> ans;
    for(int i=p; i<n; i++){
        if(ind[a[i]].back()==i){
            ans.push_back(a[i]);
        }else{
            i=*upper_bound(ind[a[i]].begin(), ind[a[i]].end(), i);
        }
    }
    for(int i=0; i<ans.size(); i++){
        cout<<ans[i];
        if(i<(int)ans.size()-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 142328
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	x--,y--;
	vector<int> edges[2000];
	for (int i=0;i<n-1;i++){
		edges[i].push_back(i+1);
		edges[i+1].push_back(i);
	}
	edges[x].push_back(y);
	edges[y].push_back(x);

	vector<int> ans(n);
	for (int s=0;s<n;s++){
		vector<int> dist(n,1e9);
		queue<int> q;
		dist[s]=0;
		q.push(s);
		while (q.size()){
			int i=q.front();
			q.pop();
   			for(int k=0;k<edges[i].size();k++){
   				int j=edges[i][k];
				if (dist[j]==1e9){
					dist[j]=dist[i]+1;
					q.push(j);
				}
			}
		}
		for (int i=s+1;i<n;i++) ans[dist[i]]++;
	}
	for (int i=1;i<n;i++) cout<<ans[i]<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long dp[N+1];
    for (int i = 0; i <= N; i++) {
        dp[i] = N;
    }

    dp[0] = 0;
    for (int n = 1; n <= N; n++) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            dp[n] = min(dp[n], dp[n-pow6] + 1);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            dp[n] = min(dp[n], dp[n-pow9] + 1);
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            int X, Y;
            cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    rep(mask,(1<<n)){
        int cnt = 0;
        bool ok = true;
        rep(j,n){
            if(!(mask>>j & 1)) continue;
            cnt++;
            rep(k,a[j]){
                if(y[j][k] != (mask>>x[j][k] & 1)) ok = false;
            }
        }
        if(ok) chmax(ans, cnt);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
import sys
from itertools import combinations
import bisect
import math
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
cnt = 0
for a, b in combinations(l_ls, 2):
    _sum = a + b
    ind = bisect.bisect_left(l_ls, _sum)
    cnt += n - ind
print(int(math.factorial(n) // math.factorial(3) // math.factorial(n-3)) - cnt)

Measured memory_bytes: 45132
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int n; std::cin >> n;
    std::vector<int> p(n);
    for(int i=0; i<n; i++) std::cin >> p[i];

    int mi = p[0];
    int cnt = 0;
    for(int i=0; i<n; i++)
    {
        if(p[i]==std::min(mi, p[i]))
        {
            mi = std::min(mi, p[i]);
            cnt++;
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 1024
def solve():
    N,K=map(int,input().split())
    S=input()
    s2=[]
    cp='_'
    cn=0
    count={'0':0, '1':0}
    for c in S:
        if cp != c:
            if cp != '_':
                s2.append(cn)
                count[cp]+=1
            cp = c
            cn = 0
        cn += 1
    s2.append(cn)
    count[cp]+=1

    csum=[0,0,0,0,0]
    csumval=0
    for v in s2:
        csumval+=v
        csum.append(csumval)

    csum+=[csumval,csumval,csumval,csumval,csumval]
    s2_len = len(s2)
    #print(s2,s2_len)
    #print(csum)
    csumlen=len(csum)

    if count['0'] <= K:
        return csum[-1]

    #print('csumlen =',csumlen)
    ans=0
    if S[0]=='1':
        for i in range(0,s2_len+3,2):
            if 5+i+K*2>=csumlen:
                break
            ans1=csum[5+i+K*2]-csum[5+i-1]
            #print(ans1,i,i+K*2)
            ans=max(ans,ans1)
    else:
        for i in range(-1,s2_len+3,2):
            if 5+i+K*2>=csumlen:
                break
            ans1=csum[5+i+K*2]-csum[5+i-1]
            #print(ans1,i,i+K*2)
            ans=max(ans,ans1)
    return ans

print(solve())


Measured memory_bytes: 47412
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
l = int(arr_data[0][1])

arr=[]

for i in range(1,1+n):
    
    arr.append(arr_data[i][0])
    
arr.sort()


print("".join(arr))




Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n, k = map(int, input().split())

    if k & 1:
        ans = (n//k) ** 3
    else:
        kk = k // 2
        even = n // k
        odd = (n//kk) - even
        ans = even ** 3 + odd ** 3
    print(ans)


if __name__ == '__main__':
    main()


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var a = new List<int>();
            for (var i = 0; i < n; i++) {
                a.Add(cin.ReadInt);
            }

            a = a.OrderByDescending(t => t).ToList();
            var Alice = 0;
            var Bob = 0;
            for (int i = 0; i < n; i++) {
                if (i%2 == 0) {
                    Alice += a[i];
                } else {
                    Bob += a[i];
                }
            }
            WriteLine(Alice-Bob);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
  int x[5];
  for(int i = 0; i < 5; i++) scanf("%d", &x[i]);
  for(int i = 0; i < 5; i++)
    if(!x[i]) printf("%d\n", i + 1);
}

Measured memory_bytes: 3712
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int gcd(int a, int b){
  if (b>a) swap(a,b);
  if (b==0) return a;
  return gcd(b, a%b);
}

int solve(){
  int n;cin>>n;
  if (n==3){
    cout << "2 5 63" << endl;
    return 0;
  }

  vi ans;
  set<int> st;
  rep(i, 2, 30001){
    if (i%6==2){
      ans.pb(i);
      ans.pb(i+2);
      st.insert(i);
      st.insert(i+2);
    }
    if (i%6==3){
      if (st.find(i)==st.end()){
        ans.pb(i);
        ans.pb(i+6);
        st.insert(i);
        st.insert(i+6);
      }
    }
    if (sz(ans)>=n-1) break;
  }

  rep(i, 2, 30001){
    if (i%6==0){
      ans.pb(i);
    }
    if (sz(ans)==n) break;
  }

  assert(sz(ans)==n);
  rep(i, sz(ans)) cout << ans[i] << (i!=sz(ans)-1 ? " " : "\n");

  int s = accumulate(all(ans), 0LL);
  int g = 0;
  vi c(30001);
  each(el, ans){
    assert(gcd(el, s-el)!=1);
    c[el]++;
    assert(c[el]<=1);
    g = gcd(g, el);
  }
  assert(g==1);

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1532
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<n;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; }
int main(){
  int H,tree[100001];
  scanf("%d",&H);
  for(int i=1;i<=H;i++) scanf("%d",&tree[i]);
  for(int i=1;i<=H;i++){
    cout<<"node "<<i<<": key = "<<tree[i]<<", ";
    if(parent(i)>=1) cout<<"parent key = "<<tree[parent(i)]<<", ";
    if(left(i)<=H) cout<<"left key = "<<tree[left(i)]<<", ";
    if(right(i)<=H) cout<<"right key = "<<tree[right(i)]<<", ";
    cout<<endl;
  }
  return(0);
}



Measured memory_bytes: 3220