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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);
    FastIO;

    int n,m;

    while(cin>>n>>m){
        int a[m] , b[m] , unlocks[m];
        for(int i=0; i<m; i++){
            cin>>a[i]>>b[i];
            unlocks[i] = 0;
            for(int j=0; j<b[i]; j++){
                int x;
                cin>>x;
                unlocks[i] |= 1<<(x-1);
            }
        }
        int M = 1<<n;
        lli dp[M];
        dp[0] = 0;
        for(int mask=1; mask<M; mask++){
            dp[mask] = 1e18;
            for(int i=0; i<m; i++){

                int need = mask;
                for(int j=0; j<12; j++){
                    if(check(mask,j) && check(unlocks[i],j)) need = reset(need,j);
                }
                dp[mask] = min(dp[mask] , a[i]+dp[need]);
            }
        }
        if(dp[M-1] == 1e18) dp[M-1] = -1;
        cout<<dp[M-1]<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
i = 10**(n-1)
if n==1:
    i = 0
no = False
while i<10**n:
    for j in range(m):
        if int(str(i)[sc[j][0]-1])==sc[j][1]:
            pass
        else:
            no = True
    if no == False:
        print(i)
        break
    else:
        i+=1
    no = False
else:
    print(-1)



Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, k = LI()


left = 0
right = 2 * 10 ** 18
L = LIR(n)
while left <= right:
    mid = (left + right) // 2
    flag = False
    ret = 0
    for w, d in L:
        if w == mid:
            ret += 1
        elif w < mid:
            ret += 1
            ret += (mid - w) // d
    if ret >= k:
        flag = True
        right = mid - 1
    else:
        flag = False
        left = mid + 1



if flag:
    print(mid)
else:
    print(mid + 1)

Measured memory_bytes: 57948
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int sum(int n){
  return n*(n+1)/2;
}

int main(){
  int a,b;
  cin >> a >> b;
  int Ans;
  Ans = sum(b-a) - b;
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 256
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

bool isSorted(int arr[] , int n)
{
    REP(i,n)
    {
        if(arr[i+1]<arr[i])
        {
            return false;
        }
    }
    
    return true;
}

int main()
{
	fastIOS();

	int n; cin >> n;
    int arr[n];
    int sortedArr[n];
    
    REP(i,n){
        cin >> arr[i];
        sortedArr[i] = arr[i];
    }
    
    sort(sortedArr , sortedArr + n);
    
    int cnt = 0;
    REP(i,n)
    {
        if(cnt>2)
        {
            cout <<"NO\n";
            return 0;
        }
        
        if(arr[i] != sortedArr[i]){
            cnt++;
        }
    }
    
    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3

import itertools
import sys


DELTAS = [(1, 0), (-1, 0), (0, 1), (0, -1)]


class UnionFind(object):

    def __init__(self, number_of_nodes):
        self.par = list(range(number_of_nodes))
        self.rank = [0] * number_of_nodes
        self.groups = [{i} for i in range(number_of_nodes)]

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def in_the_same_set(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def elements_of_group(self, node):
        return self.groups[self.root(node)]

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.groups[x].update(self.groups[y])
            self.groups[y].clear()
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def solve(h, w, stage):
    n = h * w
    uf = UnionFind(n)
    for r0, c0 in itertools.product(range(h), range(w)):
        x0 = w * r0 + c0
        ib = stage[r0][c0]
        for dr, dc in DELTAS:
            r, c = r0 + dr, c0 + dc
            if 0 <= r < h and 0 <= c < w and ib != stage[r][c]:
                x = w * r + c
                uf.unite(x0, x)
    res = 0
    is_black = [None] * n
    for r0, c0 in itertools.product(range(h), range(w)):
        x0 = w * r0 + c0
        is_black[x0] = stage[r0][c0]
    for x1 in range(n):
        eg = uf.groups[x1]
        # print(x1, eg, file=sys.stderr)
        total = len(eg)
        num_black = sum(is_black[x] for x in eg)
        res += (total - num_black) * num_black
    return res


def main():
    h, w = (int(z) for z in input().split())
    stage = [[c == "#" for c in input()] for _ in range(h)]
    res = solve(h, w, stage)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 112028
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll n,a,b,c,d,e,k,l,m,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    
    cin>>n;
    
    
    cout<<setprecision(10)<<((n+1)/2)/(double)n<<endl;
}






Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class ALDS1_1B
    {
        static void Main(string[] args)
        {
            int[] iArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            int x = iArr[0];
            int y = iArr[1];
            Console.WriteLine(GCD(x, y));

            Console.ReadLine();
        }

        static int GCD(int _x, int _y)
        {
            int retval;
            int x = Math.Max(_x, _y);
            int y = Math.Min(_x, _y);
            if (y == 0)
            {
                retval = x;
            }
            else
            {
                retval = GCD(y, x % y);
            }

            return retval;
        }
    }
}

Measured memory_bytes: 9508
import Data.Array.IO
import Data.IORef
import Control.Monad

main :: IO ()
main = do
  [n, m] <- (map read . words) <$> getLine :: IO [Int]
  imA <- newArray ((0, 0), (n - 1, n - 1)) '_' :: IO (IOUArray (Int, Int) Char)
  forM_ [0..n - 1] $ \i -> do
    row <- getLine
    forM_ [0..n - 1] $ \j -> writeArray imA (i, j) (row!!j)

  imB <- newArray ((0, 0), (m - 1, m - 1)) '_' :: IO (IOUArray (Int, Int) Char)
  forM_ [0..m - 1] $ \i -> do
    row <- getLine
    forM_ [0..m - 1] $ \j -> writeArray imB (i, j) (row!!j)

  checked <- check imA imB n m
  putStrLn $ if checked then "Yes" else "No"

check imA imB n m = do
  ng <- newIORef False
  forM_ [0..n - m] $ \x ->
    forM_ [0..n - m] $ \y -> do
      ident <- isIdent imA imB m x y
      when ident $ writeIORef ng True

  readIORef ng

isIdent :: IOUArray (Int, Int) Char -> IOUArray (Int, Int) Char -> Int -> Int -> Int -> IO Bool
isIdent imA imB m x y = do
  differ <- newIORef False
  forM_ [0..m - 1] $ \i ->
    forM_ [0..m - 1] $ \j -> do
      cellA <- readArray imA (x + i, y + j)
      cellB <- readArray imB (i, j)
      when (cellA /= cellB) $ writeIORef differ True

  not <$> readIORef differ

Measured memory_bytes: 1020
import collections

N = int(input())
A = list(map(int, input().split()))
diff = [0]*N
summ = [0]*N
count = 0
for i in range(N):
    diff[i] = i - A[i]
    summ[i] = A[i] + i

c_diff = collections.Counter(diff)
c_summ = collections.Counter(summ)
for k in c_diff.keys():
    count = count + c_diff[k]*c_summ[k]
print(count)


Measured memory_bytes: 63376
N, P = map(int, input().split())
S = [int(s) for s in input()]

if P == 2 or P == 5:
    print(sum(i for i, s in enumerate(S, 1) if s % P == 0))
    quit()

C = [0] * P
tens = 1
cur = 0
for s in reversed(S):
    cur = (cur + s * tens) % P
    C[cur] += 1
    tens = (tens * 10) % P

print(C[0] + sum(c * (c - 1) // 2 for c in C))

Measured memory_bytes: 5096
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

struct UnionFind {
  vector<int> p;
  UnionFind (int n) { p.assign(n, -1); }
  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
  void merge(int x, int y) { if (root(x) != root(y)) p[root(y)] = x; }
};

int main() {
  while(1) {
    int n,m;
    cin>>n>>m;
    if(!n)break;
    vector<tuple<int,int,int>> g;
    REP(i,m) {
      int a,b,w;
      cin>>a>>b>>w;
      --a;--b;
      g.emplace_back(w,a,b);
    }
    sort(begin(g),end(g));
    int mnslim = 100000;
    REP(i,m) {
      UnionFind u(n);
      int ind = n;
      for(int j=i;j<m;++j) {
        int a,b,w;
        tie(w,a,b) = g[j];
        if(u.root(a)!=u.root(b)) {
          --ind;
          u.merge(a,b);
          if (ind == 1) {
            mnslim = min(mnslim, w - get<0>(g[i]));
            break;
          }
        }
      }
    }
    if (mnslim < 100000)
      cout<<mnslim<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int h,w;
char c[1252][1252];

int main(){
	scanf("%d%d",&h,&w);
	REP(i,h)scanf("%s",c[i]);
	int ans = 0;
	{
		int mn=1e9, mx=-1e9;
		REP(i,h)REP(j,w)if(c[i][j]=='B'){
			CHMIN(mn,i+j);
			CHMAX(mx,i+j);
		}
		CHMAX(ans, mx-mn);
	}
	{
		int mn=1e9, mx=-1e9;
		REP(i,h)REP(j,w)if(c[i][j]=='B'){
			CHMIN(mn,i-j);
			CHMAX(mx,i-j);
		}
		CHMAX(ans, mx-mn);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4332
D={'M':0,'A':0,'R':0,'C':0,'H':0}
for k in range(int(input())):
  s=input()
  if s[0] in D.keys():
    D[s[0]]+=1

t,v=0,list(D.values())
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      t+=v[i]*v[j]*v[k]

print(t)


Measured memory_bytes: 9100
//K.Chaitanya
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//std::ios::sync_with_stdio(false);
int main(){
    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	if(n==2){
		cout<<a[1]<<" "<<a[0]<<endl;
		return 0;
	}
	ll b=a[n-1];
	ll c=a[n-1]/2;
	ll idx=lower_bound(a,a+n,c)-a;
	cout<<b<<" ";
	ll ans=a[idx];
	if(idx>0){
		if((c-a[idx-1])<(a[idx]-c)) ans=a[idx-1];
	}
	cout<<ans<<endl;
	return 0;
}


































Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<climits>
#define ll long long
#include<cmath>
using namespace std;
ll dptopdown( vector<vector<ll>> &store, vector<vector<ll>> &dp1, ll point, int i, int j){
    //cout<<"fun entered with" <<point<<endl ;
    ll max_num = INT_MIN;
    if( i == store.size()-1 ){
        //cout<<"met last"<<endl;
        return point;
    }
    if(dp1[i][j] != -1){
        return dp1[i][j];
    }
    for(int k=1; k<=3; k++){
        if(k != j){
            max_num = max(max_num, dptopdown(store,dp1,store[i+1][k], i+1, k));
        }
    }
    dp1[i][j] = point + max_num;
    return point + max_num;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<vector<ll>> s(n+2, vector<ll>(4,0));
    vector<vector<ll>> dp(n+2, vector<ll>(4,-1));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=3; j++) {cin>>s[i][j];    }
    }
    ll ans;
    //cout<<dptopdown(s,dp,s[1][1], 1,1);
    ans = max( dptopdown(s,dp,s[1][1],1,1),dptopdown(s,dp,s[1][2],1,2) );
    ans = max(ans, dptopdown(s,dp,s[1][3],1,3));
    cout<<ans;

}


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

int main(){
    double d;

    while(cin>>d){
        if(d<=48.00){
            cout<<"light fly"<<endl;
        }else if(d>48.00 && d<=51.00){
            cout<<"fly"<<endl;
        }else if(d>51.00 && d<=54.00){
            cout<<"bantam"<<endl;
        }else if(d>54.00 && d<=57.00){
            cout<<"feather"<<endl;
        }else if(d>57.00 && d<=60.00){
            cout<<"light"<<endl;
        }else if(d>60.00 && d<=64.00){
            cout<<"light welter"<<endl;
        }else if(d>64.00 && d<=69.00){
            cout<<"welter"<<endl;
        }else if(d>69.00 && d<=75.00){
            cout<<"light middle"<<endl;
        }else if(d>75.00 && d<=81.00){
            cout<<"middle"<<endl;
        }else if(d>81.00 && d<=91.00){
            cout<<"light heavy"<<endl;
        }else if(d>91.00){
            cout<<"heavy"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1220
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val s = inputs.head

  println(solve(s))

  private def solve(s: String): Int = {
    var aIndex = -1
    var zIndex = -1
    val end = s.size - 1
    (0 until end).foreach { i =>
      s(i) match {
        case 'A' if aIndex == -1 => aIndex = i
        case _ => ()
      }

      s(end - i) match {
        case 'Z' if zIndex == -1 => zIndex = end - i
        case _ => ()
      }

      if(aIndex != -1 && zIndex != -1) {
        return zIndex - aIndex + 1
      }
    }
    return -1
  }
}

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

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int tc,par[200005],vis[200005];
vector<int>graph[200005];

void bfs(int n){
    for(int i=1; i<=n; i++){
        vis[i]=0;
        par[i]=i;
    }
    queue<int>q;
    q.push(1);
    vis[1]=1;
    par[1]=0;
    while(!q.empty()){
        int x=q.front(); q.pop();
        for(int i=0; i<graph[x].size(); i++){
            int y=graph[x][i];
            if(!vis[y]){
                vis[y]=1;
                par[y]=x;
                q.push(y);
            }
        }
    }
    return;
}

void solve(){

    int n,m,x,y;
    cin>>n>>m;
    for(int i=1; i<=m; i++){
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    bfs(1);
    bool ans=1;
    for(int i=2; i<=n; i++){
        if(par[i]==i){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2; i<=n; i++){
        cout<<par[i]<<"\n";
    }
}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}







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

using namespace std;

int n,remi[5]={2,5,63,20,30};
int A[40009],sum;
int main()
{
	cin >> n ;
	if(n<=5)
	{
		for(int i=0;i<n;i++)
			printf("%d ",remi[i]); puts("");
		return 0 ;
	}
	for(int i=0;i<5000;i++)
		A[i*4+1]=i*6+2,A[i*4+2]=i*6+3,A[i*4+3]=i*6+4,A[i*4+4]=i*6+6;
	for(int i=1;i<=n;i++) sum+=A[i];
	if(sum%6==2) A[1]=30000;
	if(sum%6==3) A[2]=30000;
	if(sum%6==5) A[2]=29998;
	for(int i=1;i<=n;i++) printf("%d ",A[i]); puts("");
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> table(h, vector<char>(w));

    vector<bool> hd(h, 0);
    vector<bool> wd(w, 0);

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> table[i][j];
            if (table[i][j] == '#') {
                hd[i] = 1;
                wd[j] = 1;
            }
        }
    }

    vector<vector<char>> ans(h, vector<char>(w));
    int ansi = 0, ansj = 0;

    for (int i = 0; i < h; i++) {
        if (hd[i] == 1) {
            ansj = 0;
            for (int j = 0; j < w; j++) {
                if (wd[j] == 1) {
                    ans[ansi][ansj] = table[i][j];
                    ansj++;
                }
            }
            ansi++;
        }
    }

    for (int i = 0; i < ansi; i++) {
        for (int j = 0; j < ansj; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i,N)
  {
    cin >> S[i];
  }
  sort(ALL(S));
  string ans;
  rep(i,N)
  {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}


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

void solve(){
    long long x;
    cin>>x;
    cout<<((((int)(x/500))*1000)+((int)(x%500)/5)*5);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();    
    return 0;
}

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

int main(void)
{
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> data(q);
  vector<int> point(n);
  for (int i = 0; i < q; i++)
  {
    cin >> data[i];
    point[data[i]-1] += 1;
  }
   for (int i = 0; i < n; i++)
  {
    point[i] += k;
    point[i] -= q;
    if(point[i] < 1)
    {
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
}

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

int main() {
  
  int N, X;
  cin >> N;
  
  X = N - (N / 1000) * 1000;
 
  if (N % 1110 <= 9 || X % 111 == 0) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll w=0,h=0;
    for(int i=n-1;i>0;i--){
        if(a[i]==a[i-1]&&w!=0){
            h=a[i];
            break;
        }
        if(a[i]==a[i-1]) w=a[i],i--;
    }
    cout<<w*h;
}

Measured memory_bytes: 4020
//ios::sync_with_stdio(false);
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int Mod=998244353;
const int N=3000010;
const int maxn=3000001;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
LL jc[N],ni[N],n,m;
LL C(LL n,LL m){return jc[n]*ni[m]%Mod*ni[n-m]%Mod;}
LL Calc(LL n,LL m,LL js){
	LL ans=0;
	int ma=min(n,m);
	F(i,0,ma){
		if((i+m)&1)continue;
		ans+=C(n,i)*C(js+(m-i)/2+n-1,n-1);
		ans%=Mod;
	}
	return ans;
}
LL Pow(LL x,LL bs){
	LL an=1;
	for(;bs;bs>>=1,x=x*x%Mod)
		if(bs&1)an=an*x%Mod;
	return an; 
}
void Pre(){
	jc[0]=ni[0]=1;
	F(i,1,maxn)jc[i]=jc[i-1]*i%Mod;
	ni[maxn]=Pow(jc[maxn],Mod-2);
	D(i,maxn-1,1)ni[i]=ni[i+1]*(i+1)%Mod;
}
int main(){
	Pre();
	n=R();m=R();
	LL ans=Calc(n,m,m);
	ans-=n*(Calc(n,m,0)-Calc(n-1,m,0));
	ans%=Mod;ans+=Mod;ans%=Mod;
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 47104
#include<stdio.h>
int main()
{
	int n,x=0,t=0;
	char s[101];

	scanf("%d%s",&n,s);

	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x++;
			t=x>t?x:t;
		}
		else if(s[i]=='D')
			x--;
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int A = sc.nextInt();
    int B = sc.nextInt();

    if (A<10 && B<10){
      System.out.println(A*B);
    }else{
      System.out.println(-1);
    }

  }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

struct Dice {
    int up, front, right, left, back, down;
    Dice(){}
    Dice(int _up, int _front, int _right, int _left, int _back, int _down) 
    :up(_up), front(_front), right(_right), left(_left), back(_back), down(_down) 
    {}
    void east() {
        int tmp = this->up;
        this->up = this->left;
        this->left = this->down;
        this->down = this->right;
        this->right = tmp;
    }
    void west() {
        int tmp = this->up;
        this->up = this->right;
        this->right = this->down;
        this->down = this->left;
        this->left = tmp;
    }
    void south() {
        int tmp = this->up;
        this->up = this->back;
        this->back = this->down;
        this->down = this->front;
        this->front = tmp;
    }
    void north() {
        int tmp = this->up;
        this->up = this->front;
        this->front = this->down;
        this->down = this->back;
        this->back = tmp;
    }
    void toRight() {
        int tmp = this->front;
        this->front = this->left;
        this->left = this->back;
        this->back = this->right;
        this->right = tmp;
    }
    void print() {
        printf("up: %d, down: %d, front: %d, back: %d, left: %d, right: %d\n"
        , this->up, this->down, this->front, this->back, this->left, this->right);
    }
    bool operator == (Dice& dice) {
        if(this->up == dice.up
        && this->down == dice.down
        && this->front == dice.front
        && this->back == dice.back
        && this->left == dice.left
        && this->right == dice.right) return true;
        else return false;
    }
};

int main() {
    int n, up, front, right, left, back, down;
    cin >> n;
    Dice dice[n];
    for(int i = 0; i < n; ++i) {
        cin >> up >> front >> right >> left >> back >> down;
        dice[i] = Dice(up, front, right, left, back, down);
    }
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            if(dice[i].up == dice[j].left) dice[j].east();
            if(dice[i].up == dice[j].right) dice[j].west();
            if(dice[i].up == dice[j].front) dice[j].north();
            if(dice[i].up == dice[j].back) dice[j].south();
            if(dice[i].up == dice[j].down) {
                dice[j].south();
                dice[j].south();
            }
            for(int k = 0; k < 4; ++k) {
                dice[j].toRight();
                if(dice[i] == dice[j]) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3096
H,W = map(int,input().split())
S=[]
for i in range(H):
     S.append(input())
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            print("#",end="")
        else:
            rec = 0
            for d in [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]:
                nx,ny = i+d[0],j+d[1]
                if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "#":
                    rec += 1
            print(rec,end="")
            
    print()


Measured memory_bytes: 3444
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=100+10,maxm=10000+10;
int n,m;
int v[maxn],w[maxn],f[maxm];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>v[i]>>w[i];
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++)
		for(int j=w[i];j<=m;j++)
			f[j]=max(f[j],f[j-w[i]]+v[i]);
	cout<<f[m]<<endl;
	return 0;
}

Measured memory_bytes: 1212
o = input()
e = input()
ans = ''
if len(o)==len(e):
    for i in range(len(o)):
        ans += o[i]
        ans += e[i]
else:
    for i in range(len(e)):
        ans += o[i]
        ans += e[i]
    ans += o[-1]
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	VI a(n);
	rep(i, n)cin >> a[i];
	int min = *min_element(ALL(a));
	int max = *max_element(ALL(a));
	LL sum = accumulate(ALL(a), 0LL);
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
/* imp functions
	sorting arrays - sort(array,array+n);
	sorting vectors - v.sort(v.begin(),v.end());
	erasing element of vector - v.erase(v.begin()+i);
	inserting element in vector - v.insert(v.begin()+i,element);
	reversing vector - v.reverse(v.begin(),v.end());
	finding size of string - str.length();
	finding size of vector - v.size();
*/
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define ll long long 
#define pb push_back
#define gcd __gcd
// checking whether a number is prime or not
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_less(ll n){
    ll array[n];
    vector<ll> factor;
    for(ll i=1;i<=n;i++) array[i]=i;
    ll prime[n];
    for(ll i=0;i<n;i++) prime[i]=1;
    for(ll i=2;i<=sqrt(n);i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returning vector containing index refering to elements of normal array after sorting it
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
//calculating power in order logn returns x^y
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
int main(){
    ll array[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll n;
    cin>>n;
    cout<<array[n-1];
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n,flag=0;
   cin>>n;
   int a[n],b[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i]>>b[i];
   }
   for(int i=0;i<n-2;i++)
   {
       if(a[i]==b[i])
       {
           if(a[i+1]==b[i+1] && a[i+2]==b[i+2])
           {
               flag=1;
               cout<<"Yes"<<endl;
               break;
           }
       }
   }
   if(flag==0)
   {
       cout<<"No"<<endl;
   }
   return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000005;

signed main() {
    int a,b;
    cin>>a>>b;
    int l=max(10*b,(25*a+1)/2);
    int r=min(10*b+10,(25*a+25+1)/2);
    int L=l+0.1,R=r+0.1;
    if(L<R) cout<<L;
    else cout<<-1;
}


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

vector<int> sieve(const int n) {
  //prime[i]:iを割り切る最小の素因数
  //ただし、prime[1]=1;
  vector<int> prime(n);
  iota(prime.begin(),prime.end(),0);
  for (int i = 2; i*i < n; ++i) {
    if (prime[i] < i) continue;
    for (int j=i*i;j<n;j+=i){
      if (prime[j]==j) prime[j] = i;
    }
  }
  //res:素数の集合
  vector<int> res;
  for(int i=2;i<n;i++){
      if(prime[i]==i){
          res.emplace_back(i);
      }
  }
  return prime;
}

vector<int> factor(int i, const vector<int>& min_factor) {
  vector<int> res;
  while (i > 1) {
    res.push_back(min_factor[i]);
    i /= min_factor[i];
  }
  //素因数のsetが欲しいなら、以下のコメントアウトを解除
  sort(res.begin(),res.end());
  decltype(res)::iterator result = unique(res.begin(), res.end());
  res.erase(result, res.end());
  return res;
}


int main(){
    int n;cin>>n;
    auto x=sieve(1000005); 
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    set<int> s;
    int co=a[0];
    for(int i=0;i<n;i++){
        co=gcd(co,a[i]);
    }
    if(co!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        auto tmp=factor(a[i],x);
        for(int j=0;j<tmp.size();j++){
            if(s.find(tmp[j])!=s.end()){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            else{
                s.insert(tmp[j]);
            }
        }
    }
    cout<<"pairwise coprime"<<endl;    

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long k; 
    cin >> k;
    int a[n];
    long long mod = 1e9+7;
    for(int i = 0; i < n;i++){
        cin >> a[i]; 
    }
    long long temp1 = 0;
    long long temp2 = 0;
    long long ans = 0;

    long long alphak = (k+1)*k/2%mod;
    long long alphak2 = k*(k-1)/2%mod;
    

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;

            if(i < j){
                if(a[i] > a[j]) temp1++; 
            }
            if(i > j){
                if(a[i] > a[j]) temp2++;
            }             
        }
    }
    ans = ((temp1 * alphak)+(temp2 * alphak2)) % mod;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[100];
	int n, i, j, k, c, d=0;
	
	scanf("%s",s);
	n=strlen(s);
	
	for(i=1;i<=n;i++){   //文字数
	    for(j=0;j<=n-i;j++){   //初めの文字
	        c=0;
	        for(k=j;k<i+j;k++){
	            if((s[k]=='A')||(s[k]=='C')||(s[k]=='G')||(s[k]=='T')) c++;
	            else break;
	        }
	        if(c>d) d=c;
	    }
	}
	printf("%d\n",d);
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn digit_sum(n: i64) -> i64 {
    if n == 0 {
        return 0;
    }
    else {
        return n % 10 + digit_sum(n/10);
    }
}

fn gen(n: i64, m: i64) -> i64 {
    if m == 0 {
        return n;
    }
    else {
        return gen(n * 10 + 9, m-1);
    }
}

fn main() {
    let inf = 1i64 << 62;
    let mut count = 0;
    let k = read_i64();
    let mut res = vec![];
    for i in 1..9+1 {
        res.push(i);
    }
    for i in 1..9+1 {
        res.push(gen(i,1));
    }
    for d in 3..16 {
        for i in 100..1000 {
            let n = gen(i, d-3);
            let mut p = 1;
            let mut ok = true;
            for _ in 0..17 {
                let mut m = n + p;
                if ! (n * digit_sum(m) <= m * digit_sum(n)) {
                    ok = false;
                }
                p *= 10;
            }
            if ok {
                if res.len() >= k as usize {
                    break;
                }
                res.push(n);
            }
        }
    }
    for i in 0..k {
        println!("{}", res[i as usize]);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(2e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    // pre();
    int tc;
    // cin>>tc;
    tc=1;
    while(tc--){
    	int ans = 0;
    	string s;
    	cin>>s;
    	int i=0,j=s.size()-1;
    	while(i<=j)
    	{
    		if(s[i]!=s[j])
    			ans++;
    		i++,j--;
    	}
    	cout<<ans<<endl;
    	
    }
    

    return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll a[212345],ans=0;
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    rep(i,n){
    	cin>>a[i];
    	a[i]-=i;
    
    }
    sort(a,a+n);
    rep(i,n){
    	ans+=abs(a[n/2]-a[i]);
    }
    cout<<ans<<endl;
    return 0;  
    
}



Measured memory_bytes: 1792
#include <stdio.h>


int main(void){
	int i;
	unsigned long long  k;//<=50*10^16
	scanf("%lld",&k);
	int n=50;//数列長は50以下
	unsigned long long a[n];//<=10^16+1000
	for(i=0;i<n;i++){a[i]=n-1;}

	unsigned long long roop=0L;
	unsigned long long amari=0L;
	
	roop=k/50;
	amari=k%50;
	for(i=0;i<n;i++){a[i]=n-1+roop;}

	for(i=0;i<amari;i++){a[i]+=(n-amari+1LL);}
	for(i=amari;i<n;i++){a[i]-=amari;}



	printf("%lld\n", n);
	for(i=0;i<n;i++){printf("%lld ", a[i]);}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) {
            w.push_back(i);
        }
    }
    ll m = w.size();
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = w[rand() % m];
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    auto f = [&] () {
        double prob = (clock() - start) / CLOCKS_PER_SEC / 1.95;
        return ((double)rand() / RAND_MAX < prob);
    };
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll change_at2 = rand() % d, into2 = w[rand() % m];
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score && f()) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int x;
    scanf("%d", &x);
    puts(x >= 30 ? "Yes" : "No");
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        for (int i = 0 ; i < n ; i++) {
            if (a[i] == b[n - 1]) {
                System.out.println(b[n - 2]);
            } else {
                System.out.println(b[n - 1]);
            }
        }
    }

}

Measured memory_bytes: 91180
#include <stdio.h>

int main(void){

  long n,a,b;
  scanf("%ld %ld %ld", &n,&a,&b);

  long set = n/(a+b);
  set *= a;
  long amari = n%(a+b);
  if (amari > a) {
    amari = a;
  }
  long answer = set+amari;
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int K, A, B; cin >> K >> A >> B;
    if (A <= (B / K * K)) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
k,s = map(int,input().split())
n = 3*k-s
ans = 0
if n == 0:
  ans = 1
elif n<0:
  None
else:
  for i in range(min(k,n),min(k-1,(n-1)//3),-1):
    t = min(k,n-i,i)
    for j in range(t,min(t-1,(n-i-1)//2),-1):
      l = n-i-j
      if i!= j and j != l:
        ans += 6
      elif i == j == l:
        ans += 1
      else:
        ans += 3
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	int choco_num = X;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		choco_num += (D-1)/A + 1;
	}
	cout << choco_num;
}


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

int n, c ;
int d[33][33] ;
int g[505][505] ;

void getInput(){
    cin >> n >> c ;

    for(int i = 1 ; i <= c ; i++){
        for(int j = 1 ; j <= c ; j++){
            cin >> d[i][j] ;
        }
    }

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n; j++){
            cin >> g[i][j] ;
        }
    }
}

int main(){

    getInput() ;

    vector<pair<int, int> > points[3] ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n; j++){
            points[(i + j) % 3].push_back({i, j}) ;
        }
    }

    vector<pair<int, int> > best3[3] ;

    for(int i = 0 ; i < 3 ; i++){
        vector<pair<int, int> > costs ; // cost, color

        for(int j = 1 ; j <= c ; j++){ // color select
            int cost = 0 ;
            for(auto p : points[i]){
                cost += d[g[p.first][p.second]][j] ;
            }
            costs.push_back({cost, j}) ;
        }

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

        best3[i].push_back(costs[0]) ;
        best3[i].push_back(costs[1]) ;
        best3[i].push_back(costs[2]) ;
    }

    int ans = INT_MAX ;

    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            for(int k = 0 ; k < 3 ; k++){
                if(best3[0][i].second != best3[1][j].second && best3[1][j].second != best3[2][k].second && best3[2][k].second != best3[0][i].second)
                    ans = min(best3[0][i].first + best3[1][j].first + best3[2][k].first, ans) ;
            }
        }
    }

    cout << ans << endl ;

    return 0 ;
}

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

int main(){
  string s;
  cin >> s;
  int mx = 0;
  int A = 0, B = 0;
  
  for(int i=0; i<s.size(); ++i){
    if(s[i] == 'A'){
      A = i;
      break;
    }
  }

  for(int i=s.size(); i>-1; --i){
    if(s[i] == 'Z'){
      B = i;
      break;
    }
  }
  cout << B - A + 1;

}

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

int main() {
  int N; // [1, 100]
  cin >> N;
 
  if (N==0){
    cout << 0 << endl;
    return 1;
  }

  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());
  int s = 1;
  int prev = a.at(0);
  for(int i=1;i<N;i++){
    if(prev != a.at(i)) s++;
    prev = a.at(i);
  }
  cout << s << endl;
}


Measured memory_bytes: 256