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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int H, W, h, w, ans[1000][1000];

int main() {
	cin >> H >> W >> h >> w;
	
	inc(i, 1000) {
	inc(j, 1000) {
		ans[i][j] = ((i + 1) % h == 0 && (j + 1) % w == 0 ? - 300 * (h * w - 1) - 1 : 300);
	}
	}
	/*
	int hr = (H + h - 1) / h * h - H - 1;
	int wr = (W + w - 1) / w * w - W - 1;
	if(H % h != 0) { inc(j, W) { ans[H - 1][j] += hr * 300; } }
	if(W % w != 0) { inc(i, H) { ans[i][W - 1] += wr * 300; } }
	if(H % h != 0 && W % w != 0) { ans[H - 1][W - 1] += hr * wr * 300; }
	*/
	int sum = 0;
	inc(i, H) {
	inc(j, W) {
		sum += ans[i][j];
	}
	}
	
	cout << (sum > 0 ? "Yes" : "No") << endl;
	if(sum > 0) {
		inc(i, H) {
		inc(j, W) {
			cout << (j == 0 ? "" : " ") << ans[i][j];
		} cout << "\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 5248
n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

list = []
maxnum = max(d.values())

for i in d:
    if d[i] == maxnum:
        list.append(i)
list.sort()
for i in list:
    print(i)


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

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

    int h,w;
    cin >> h >> w;
    
    ll sum = (ll) h * w;
    
    ll ans = INF;
    
    //w3
    for(int i=1; i<w; i++){
        ll a = (ll) h * i;
        ll b = (ll) h * ((w - i) / 2);
        // ll c = (ll) h * (w - ((w - i) / 2));
        ll c = sum - a - b;
        if(a==0 || b==0 || c==0) continue;
        // cout << a << "|" << b << "|" << c << endl;
        ans = min(max({a, b, c}) - min({a, b, c}), ans);
    }
    
    for(int i=1; i<h; i++){
        ll a = (ll) w * i;
        ll b = (ll) w * ((h - i) / 2);
        // ll c = (ll) w * ((h - i) - ((h - i) / 2));
        ll c = sum - a - b;
        if(a==0 || b==0 || c==0) continue;
        // cout << a << "|" << b << "|" << c << endl;
        ans = min(max({a, b, c}) - min({a, b, c}), ans);
    }
    
    for(int i=1; i<h; i++){
        ll a = (ll) w * i;
        ll b = (ll) (h - i) * (w / 2);
        // ll c = (ll) (h - i) * (w - w / 2);
        ll c = sum - a - b;
        if(a==0 || b==0 || c==0) continue;
        // cout << a << "|" << b << "|" << c << endl;
        ans = min(max({a, b, c}) - min({a, b, c}), ans);
    }
    
    for(int i=1; i<w; i++){
        ll a = (ll) h * i;
        ll b = (ll) (w - i) * (h / 2);
        // ll c = (ll) (w - i) * (h - h / 2);
        ll c = sum - a - b;
        if(a==0 || b==0 || c==0) continue;
        // cout << a << "|" << b << "|" << c << endl;
        ans = min(max({a, b, c}) - min({a, b, c}), ans);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
const int N=100;
const int W=10000;
int n,w,v[N],wi[N];
int dp[N+1][W+1];

int main(){
	FOR(i,0,N+1)FOR(j,0,W+1)dp[i][j]=0;
	cin>>n>>w;
	FOR(i,0,n){
		cin>>v[i]>>wi[i];
	}
	FOR(i,0,n){
		FOR(j,0,w+1){
			if(j<wi[i]){
				dp[i+1][j]=dp[i][j];
			}else{
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-wi[i]]+v[i]);
			}
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string cad1,cad2; cin>>cad1>>cad2;
	int ans=0;
	for(int i=0;i<cad1.size();i++){
		if(cad1[i]!=cad2[i]) ans++;
	}	
	cout<<ans<<"\n";
    return 0;
}	



Measured memory_bytes: 3796
// ITP1_2_B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long s; cin >> s;
	long long q = sqrtl(s);
	while(q * q >= s) q--;
	while(q * q <= s) q++;
	q--;
	if(q == 1'000'000'000){
		cout << 0 << " " << 0 << " " << q << " " << 0 << " " << 0 << " " << q << endl;
		return 0;
	}
	long long d = s - q * q;
	if(d < 1'000'000'000){
		cout << 0 + 1 << " " << 0 + 1 << " " << q + 1 << " " << -1 + 1 << " " << d + 1 << " " << q + 1 << endl;
	} else {
		d = (q + 1) * (q + 1) - s;
		cout << 0 << " " << 0 << " " << q + 1 << " " << 1 << " " << d << " " << q + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

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

int main()
{
    ll a,b;
    cin >> a >> b;
    vector<ll> fuc_a;
    vector<ll> fuc_b;
    for(ll i = 2; i * i <= a; i++){
        if(a % i != 0) continue;
        while(a % i == 0){
            a /= i;
        }
        fuc_a.push_back(i);
    }
    if(a != 1) fuc_a.push_back(a);

    for(ll i = 2; i * i <= b; i++){
        if(b % i != 0) continue;
        while(b % i == 0){
            b /= i;
        }
        fuc_b.push_back(i);
    }
    if(b != 1) fuc_b.push_back(b);

    int ans = 1;
    for(int i = 0; i < fuc_a.size(); i++){
        for(int j = 0; j < fuc_b.size(); j++){
            if(fuc_a[i] == fuc_b[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, m, s[33][33], a[505][505];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++) for(int j = 0; j < m; j++){
		cin >> s[i][j];
	}
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
		cin >> a[i][j];
	}
	
	int cnt[3][33] = {0};
	
	for(int color = 0; color < m; color++){
		for(int k = 0; k < 3; k++){
			for(int i = 0; i < n; i++) for(int j = (i*2+k)%3; j < n; j+=3){
				cnt[k][color] += s[a[i][j]-1][color];
			}
		}
	}
	
	int ans = INF;
	for(int i= 0; i < m; i++){
		for(int j = 0; j < m; j++){
			for(int k = 0; k < m; k++){
				if(i != j && j != k && i != k){
					ans = min(ans, cnt[0][i]+cnt[1][j]+cnt[2][k]);
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1280
import Data.List (nub, sort)
import Control.Monad (replicateM)

import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n <- readInt
  ds <- replicateM n readInt
  print $ mochi ds

mochi
  :: [Int] -> Int
mochi = length . nub 

Measured memory_bytes: 508
require 'prime'
loop do
  m, a, b = gets.split.map(&:to_i)
  break if m == 0
  ans = [0, 0]
  prod = 0
  Prime.each.lazy.take_while{ |p| p <= Math.sqrt(100000).to_i && p * p <= m }.each do |p|
    q = Prime.each.lazy.drop_while{ |q| q < p  }
                       .take_while{ |q| a * q <= b * p && p * q <= m }.to_a.last
    if q && prod < p * q
      ans = [p, q]
      prod = p * q
    end
  end
  puts ans * ' '
end

Measured memory_bytes: 9840
import sys
from collections import deque

input = sys.stdin.readline


def bfs(H, W, maze, dist, sh, sw):
    queue = deque([[sh, sw]])
    dist[sh][sw] = 0
    while queue:
        h, w = queue.popleft()
        for i, j in [(1, 0), (-1, 0), (0, -1), (0, 1)]:
            next_h, next_w = h + i, w + j
            if not ((0 <= next_h <= H - 1) and (0 <= next_w <= W - 1)):
                continue
            if (maze[next_h][next_w] == ".") and (dist[next_h][next_w] == -1):
                dist[next_h][next_w] = dist[h][w] + 1
                queue.append([next_h, next_w])
    return dist

def main():
    H, W = map(int, input().split())
    s = [""] * H
    for i in range(H):
        s[i] = input().rstrip()

    dist = [[-1] * W for _ in range(H)]
    bfs(H, W, s, dist, 0, 0)
    min_n_white_of_path = dist[H-1][W-1] + 1
    if min_n_white_of_path == 0:
        print(-1)
    else:
        n_white = 0
        for i in range(H):
            n_white += s[i].count(".")
        ans = n_white - min_n_white_of_path
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
<?php
while(1){
        $a=trim(fgets(STDIN));
        if ($a==0) {
                break;
        }
        $b=trim(fgets(STDIN));
        for ($i=0; $i < $a; $i++) {
                $c="";
                $memo=$b[0];
                $count=0;
                for ($j=0; $j < strlen($b); $j++) {
                        if ($memo===$b[$j]) {
                                $count++;
                        }       else{
                                $c.=$count.$memo;
                                $memo=$b[$j];
                                $count=1;
                        }
                }
                $b=$c.$count.$memo;
        }
        echo $b.PHP_EOL;
}

Measured memory_bytes: 15276
#include<iostream>
using namespace std;
int ink[14][14] = {};

int main() {
	int x, y, s;
	char c;
	while (cin >> x >> c >> y >> c >> s) {
		x += 2; y += 2;
		if (s == 1) {
			ink[y - 1][x]++;
			ink[y][x - 1]++;
			ink[y][x]++;
			ink[y][x + 1]++;
			ink[y + 1][x]++;
		}
		else if (s == 2) {
			ink[y - 1][x - 1]++;
			ink[y - 1][x]++;
			ink[y - 1][x + 1]++;
			ink[y][x - 1]++;
			ink[y][x]++;
			ink[y][x + 1]++;
			ink[y + 1][x - 1]++;
			ink[y + 1][x]++;
			ink[y + 1][x + 1]++;
		}
		else if (s == 3) {
			ink[y - 2][x]++;
			ink[y - 1][x - 1]++;
			ink[y - 1][x]++;
			ink[y - 1][x + 1]++;
			ink[y][x - 2]++;
			ink[y][x - 1]++;
			ink[y][x]++;
			ink[y][x + 1]++;
			ink[y][x + 2]++;
			ink[y + 1][x - 1]++;
			ink[y + 1][x]++;
			ink[y + 1][x + 1]++;
			ink[y + 2][x]++;
		}
	}
	int cnt = 0, max = 0;
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (ink[i][j]) cnt++;
			if (ink[i][j] > max) max = ink[i][j];
		}
	}
	cout << 100 - cnt << endl << max << endl;
}


Measured memory_bytes: 3000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int

const int INF = 1000000007;

signed main(){
    
    int n, k; cin >> n >> k;

    double sum = 0;
    int hight = 0;
    
    while(1){
        // sum に耐えうる個数のうち, 最小のものを求める
        int l = 0; 
        int r = 100010;
        while(r - l > 1){
            int d = (r + l) / 2;
            
            double w = INF;
            if(d != 0) w = sum / d;
            if(w <= k) r = d;
            else l = d;
        }

        if(r <= n){
            hight++;
            n -= r;
            sum += r;
        }else{
            cout << hight << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef set<int>        si;

template<typename T> T sgn (T x)      {return x<0? -1:x!=0; }
template<typename T> T gcd (T a, T b) {return a ? gcd (b % a, a) : b; }
//pi=acos(-1)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define popcount __builtin_popcount
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define MOD ((int)1e9+7)
#define N (20)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll ans, n, m, x, v[N][N], c[N], a[N],pode;

void f(ll i, ll arr[], ll custo){
    if(i==n){
        pode=1;
        forn(j,0,m){
            if(arr[j]<x)pode=0;
        }
        if(pode) ans = min(ans,custo);
        return;
    }
    ll b[N];
    f(i+1,arr,custo);
    custo+=c[i];
    forn(j,0,m)b[j]=arr[j]+v[i][j];
    f(i+1,b,custo);
}

void solve(){
    scanf("%lld %lld %lld", &n, &m, &x);
    forn(i,0,n){
        scanf("%lld", c+i);
        
        forn(j,0,m){
             scanf("%lld", &v[i][j]);
        }
    }
    ans =(1e9);
    f(0,a,0);
    if(ans == (1e9))ans=-1;
    printf("%lld\n",ans);
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;//scanf("%d",&t);
    while(t--)solve();
}

Measured memory_bytes: 3864
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	f := false
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if i*j == n {
				f = true
			}
		}
	}

	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	printf("%d\n",(x-z)/(y+z));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6

using namespace std;

int main(){
    string s;
    cin >> s;
    long k;
    cin >> k;
    long count =0;
    char ans;
    bool answer=true;
    for (int i=0;i<s.size();i++){
        if(s.at(i)=='1') count++;
        else {
            ans=s.at(i);
            answer=false;
            break;
        }
    }
    if(k<=count) cout << 1 << endl;
    else cout << ans << endl;
}



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

int main(){
  string s; cin >> s;
  bool dir[4]={};
  for(int i=0; i<s.size(); i++){
    switch(s[i]){
      case 'N': dir[0]=true; break;
      case 'W': dir[1]=true; break;
      case 'S': dir[2]=true; break;
      case 'E': dir[3]=true; break;
    }
  }
  cout << ((dir[0]==dir[2]&&dir[1]==dir[3])?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m,x;
    cin>>n>>m>>x;

    vector<bool>c(n+1,true);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;

        c[a]=false;
    }

    int countp=0,countm=0;

    for (int i=x+1;i<=n;i++) {
        if(c[i]==false){
            countp++;
        }
    }
    for (int i=x-1;i>=0;i--) {
        if(c[i]==false){
            countm++;
        }
    }

    int answer=min(countp,countm);

    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

signed main(){
    int d, t, s;
    cin >> d >> t >> s;
    if((d+s-1) / s <= t) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int T[N];
   for(int i=0;i<N;i++){
       cin>>T[i];
   }
   int M;
   cin>>M;
   int P[M],X[M];
   for(int i=0;i<M;i++){
       cin>>P[i]>>X[i];
   }
   int ans[M];
   for(int i=0;i<M;i++){ans[i]=0;
       for(int j=0;j<N;j++){
      if(P[i]!=j+1) {ans[i]+=T[j];}
      else {ans[i]+=X[i];}
       }
   }
   for(int i=0;i<M;i++){
       cout<<ans[i]<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    double a[] = new double[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextDouble();
    }
    Arrays.sort(a);
    for (int i = 1; i < n; i++) {
      a[i] = (a[i] + a[i-1]) / 2;
    }
    System.out.println(a[n-1]);
  }
}


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

int N;
vector<int> a, b;
 
int main() {
    cin >> N;
    a.resize(N);
    b.resize(N, 0);
    rep(i, N) {
        cin >> a[i];
        --a[i];
    }

    int ans = 0;
    rep(i, N) {
        if(b[i]) continue;

        int t = a[i];
        if(a[t] == i) {
            ++ans;
            ++b[t];
        }
        ++b[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[200005];
int main()
{
    /*int  d,t,s;
    cin >> d >> t>> s;
    int dis = s*t;
    if(dis>=d)
        cout << "Yes\n";
    else
        cout << "No\n";*/
    string s,t;
    int mn = 1e9;
    cin >> s>> t;
    int n = (int)s.size();
    int m = (int)t.size();
    for(int i=0;i<n-m+1;i++)
    {
        int cur=0,lol=0;
        for(int j=i;j<i+m;j++)
        {
            if(s[j]!=t[cur])
                lol++;
            cur++;
        }
        mn = min(lol,mn);
    }
    cout << mn << endl;
}


Measured memory_bytes: 3628
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

A,B,C,D = map(int,input().split())
c = 0

Ac = (A-1)//C
Ad = (A-1)//D
Bc = B//C
Bd = B//D
cd = ((C*D)//gcd(C,D))
Acd = (A-1)//cd
Bcd = B//cd
print((B-Bc-Bd+Bcd) - (A-Ac-Ad+Acd)+1)

Measured memory_bytes: 3064
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll max_sum = 2500;

ll dp[51][2 * (max_sum + 5)];
ll dp_sub[51][2 * (max_sum + 5)];

ll make_idx(ll sum) { return sum + max_sum + 1; }

const ll mod = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    dp[0][make_idx(0)] = 1;
    for(ll i = 1; i <= N; i++) {
        for(ll j = 0; j < 51; j++) for(ll k = -max_sum; k <= max_sum; k++) dp_sub[j][make_idx(k)] = 0;
        for(ll j = 0; j < i; j++) for(ll k = -max_sum; k <= max_sum; k++) {
            ll cur_k_idx = make_idx(k);
            (dp_sub[j][cur_k_idx] += dp[j][cur_k_idx]) %= mod; // i <-> i
            (dp_sub[j + 1][make_idx(k - i * 2)] += dp[j][cur_k_idx]) %= mod; // hold
            if(1 <= j) {
                (dp_sub[j][cur_k_idx] += 2 * j * dp[j][cur_k_idx]) %= mod; // only one
                (dp_sub[j - 1][make_idx(k + 2 * i)] += j * j * dp[j][cur_k_idx]) %= mod; // both
            }
        }
        swap(dp, dp_sub);
    }
    cout << dp[0][make_idx(K)] << endl;
    return 0;
}


Measured memory_bytes: 4224
# include <iostream>

//old school with Pros

using namespace std;

int solve() {
    int n; 
    cin >> n;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

int main() {

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    string S;
    cin >> S;
    int N=S.size();
    rep(i,N){
        cout << "x" ;
    }
    cout << endl;
 
}

Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().split()))
    ks = [[int(arg) for arg in input().split()] for _ in range(M)]
    p = list(map(int, input().split()))
    comb = 0

    for i in range(2**N):
        flag = False
        denki = []
        for j in range(N):

            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                denki.append(j+1)  # フラグが立っていたら num に数字を詰める
        for k in range(M):
            KS = ks[k]
            idk = KS[0]
            kosuu = 0
            for l in range(1, idk+1):
                if KS[l] in denki:
                    kosuu += 1
            if kosuu % 2 != p[k]:
                flag = False
                break
            else:
                flag = True
        if flag:
            comb += 1

    print(comb)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
typedef long long ll;
//answer looked from editorial
int main()
{
	ll n;
	scanf("%lld", &n);
	if(n&1)
		printf("0\n");
	else
	{
		ll count = 0;
		for(ll i=10; i<=n; i*=5)
			count += n/i;
		printf("%lld\n", count);
	}
	return 0;
}

Measured memory_bytes: 128
import Control.Applicative

main = do
  [a,b,c] <- map read . words <$> getLine :: IO [Int]

  print $ if even a && a==b && b==c then -1 else solve a b c

  where
    solve a b c
      | odd a || odd b || odd c = 0
      | otherwise = 1 + solve ((b+c)`div`2) ((a+c)`div`2) ((a+b)`div`2)
      


Measured memory_bytes: 508
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), B;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  B = A;
  sort(B.rbegin(), B.rend());
  for (int i = 0; i < N; i++) {
    if (A[i] != B[0])
      cout << B[0] << endl;
    else
      cout << B[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 4736
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

main = do
  [a,b,c,d,e,f] <- getLine
  putStrLn $
    if (c == d) && (e==f)
       then "Yes"
       else "No"


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
  	ll n,r;
  	cin>>n>>r;
  	if(n>=10)
  	{
  		cout<<r;
  	}
  	else{
  		ll k= 100 * (10 - n);
  		cout<<r+k;
  	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100
int t = 0;
stack<int> st;
int d[N + 1], f[N + 1], V[N + 1];
int adj[N + 1][N + 1];

void dfs(int i, int n)
{
    for (int j = 0; j < V[i]; j++)
    {
        if (d[adj[i][j]] == -1)
        {
            d[adj[i][j]] = ++t;
            dfs(adj[i][j], n);
        }
    }
    f[i] = ++t;
}

int main()
{
    int n;
    cin >> n;
    V[0] = n;
    for (int i = 0; i < n; i++)
        adj[0][i] = i + 1;
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        V[u] = k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            adj[u][j] = v;
        }
    }

    for (int i = 0; i <= n; i++)
        d[i] = f[i] = -1;

    dfs(0, n);

    for (int i = 1; i <= n; i++)
        cout << i << ' ' << d[i] << ' ' << f[i] << endl;
}



Measured memory_bytes: 3136
#include<iostream>
using namespace std;
int main(){
	int num;
	int rem=0;
	int rev=0;
	cin>>num;
	int n=num;
	while(num!=0){
		rem=num%10;
		rev=rev*10+rem;
		num=num/10;
	}
	if(n==rev)
		cout<<"Yes";
		else
		cout<<"No";
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

// ユーグリッド互除法
ll GCD(ll a, ll b)
{
  if(b == 0) return a;
  else return GCD(b, a % b);
}

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  vector<ll> left(n+1,0), right(n+1,0);
  REP(i,n) left[i+1] = GCD(left[i], a[i]);
  REPR(i,n-1) right[i] = GCD(right[i+1], a[i]);
  ll ans = 0;
  REP(i,n) ans = max(ans, GCD(left[i], right[i+1]));
  
  cout << ans << '\n'; 
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=1005;

struct edge{int to,cost;};

int n,m,s,cnt[maxn];
int d[maxn];
int qh,qt,q[maxn*maxn];
bool ok=1,inq[maxn];
vector<edge>G[maxn];

int main() {
	cin>>n>>m>>s;
	for (int i=0;i<m;i++) {
		int u,v,w; cin>>u>>v>>w;
		G[u].pb(edge{v,w});
	}
	memset(d,0x3f,sizeof(d));
	d[s]=0;
	q[qt++]=s; inq[s]=1;
	while (qh<qt) {
		int u=q[qh++]; inq[u]=0;
		if (cnt[u]>m+5) {ok=0;break;}
		for (edge e:G[u]) {
			if (d[e.to]>d[u]+e.cost) {
				d[e.to]=d[u]+e.cost;
				if (!inq[e.to]) {
					q[qt++]=e.to;
					inq[e.to]=1;
					++cnt[e.to];
				}
			}
		}
	}
	if (!ok) {
		cout<<"NEGATIVE CYCLE"<<'\n';
		return 0;
	}
	else for (int i=0;i<n;i++) 
		if (d[i]==INF) cout<<"INF"<<'\n';
		else cout<<d[i]<<'\n';
}


Measured memory_bytes: 5832
#include<stdio.h>
int n,a[11][11],count,ans=0;

int main(void)
{
    scanf("%d", &n);
    for (int i = 1; i <= n;i++){
        count = i;
        while(count>=10)
            count /= 10;
        a[count][i % 10]++;
    }
    for (int i = 0; i <10;i++)
        for (int j = 0; j <10;j++)
            ans += a[i][j] * a[j][i];
    printf("%d", ans);
    return 0;
}

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

int calc(const std::array<int, 2> pos[], const int n, const int a, const int b)
{
    const long dx = pos[b][0] - pos[a][0];
    const long dy = pos[b][1] - pos[a][1];
    int zeros = 0;

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (pos[j][0] - pos[i][0] == dx &&
                pos[j][1] - pos[i][1] == dy) {
                    zeros++;
            }
        }
    }

    return n - zeros;
}

int main(int argc, char *argv[])
{
    int n;
    std::array<int,2> pos[50];
    int x, y;
    int ans;

    std::cin >> n;

    for (int i =0; i < n; i++) {
        std::cin >> x >> y;
        pos[i][0] = x;
        pos[i][1] = y;
    }

    std::sort(&pos[0], &pos[n], [](auto &a, auto &b){return (a[0]==b[0])?(a[1]<b[1]):(a[0]<b[0]);});

    if (n == 1) {
        ans = 1;
    } else {
        ans = 100;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int score = calc(pos, n, i, j);
                ans = std::min(ans, score);
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int N,M,Q;
    cin >> N >> M >> Q;
    ve<pair<int,int>> A(M);
    rep(i,M) cin >> A[i].fi >> A[i].se;
    ve<pair<int,int>> B(Q);
    rep(i,Q) cin >> B[i].fi >> B[i].se;
    
    ve<ve<int>> C(N+1,ve<int>(N+1,0));
    
    rep(i,M) C[A[i].fi][A[i].se]++;
    reps(i,1,N+1) reps(j,2,N+1) C[i][j] += C[i][j-1];
    
    rep(i,Q){
        int ans = 0;
        reps(j,B[i].fi,B[i].se+1) ans += C[j][B[i].se];
        out(ans);
    }
        
    
    
    


    return 0;
}


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

int main()
{
  int a,b,c,d,e,k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  
  if ((e-a)<=k)
    cout << "Yay!";
  else {
    cout << ":(";
  }
  return 0;
}

Measured memory_bytes: 256
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-17 15:23:07
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=200010;
i64 n,a[N],r[N],ans,vis[N],Ans,flag;
int main()
{
	n=read(); Ans=1ll<<50;
	fr(i,0,n-1){ a[i*2]=read(); a[i*2+1]=read(); }
	fr(i,0,n+n-1) r[i]=i;
	std::sort(r+1,r+n+n+1,[&](int x,int y){ return a[x]<a[y]; } );
	fr(i,1,n)
	{
		ans+=a[r[i]]; vis[r[i]/2]++;
		if(vis[r[i]/2]==2) Ans=0;
		flag|=1<<(r[i]%2);
	}
	if(flag==1||flag==2) Ans=0;
	if(Ans)
	{
		fr(i,1,n) Ans=std::min(Ans,a[r[i]/2==r[n+1]/2?r[n+2]:r[n+1]]-a[r[i]]);
	}
	printf("%lld\n",ans+Ans);
	return 0;
}

Measured memory_bytes: 4096
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;
  unsigned long long ans = 0;

  for(int i = 1; i <= n ;i++)
  {
    if(i % 3 && i % 5)
      ans += i;
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3640
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;

signed main(){
    cin >> S;
    int N = S.size();
    if(S[0] == '0' || S[N-1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    rep(i, N/2){
        if(S[i] != S[N-2-i]){
            cout << -1 << endl;
            return 0;
        }
    }

    int n = 1;
    rep(i, N-1){
        cout << n << " " << i+2 << endl;
        if(S[i] == '1') n = i+2;
    }
}

Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if(n%2 == 0 || n%5 == 0) System.out.println(-1);
        else{
        long num = 7%n, ans = 1;
        while(num != 0){
            ans++;
            num= num*10 + 7;
            num %= n;
        }
        System.out.println(ans);
        }

        sc.close();
    }
}

Measured memory_bytes: 35688
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	inputs := scanNums(2*N + (N - 1))
	A := inputs[0:N]
	B := inputs[N : 2*N]
	C := inputs[2*N:]

	ans := 0
	beforeDish := A[0]
	// fmt.Println(A)
	// fmt.Println(B)
	// fmt.Println(C)
	for i := 0; i < N; i++ {
		// fmt.Println(B[A[i]-1])
		ans += B[A[i]-1]
		if beforeDish+1 == A[i] {
			ans += C[A[i-1]-1]
		}

		beforeDish = A[i]
		// fmt.Println(ans)
	}
	fmt.Println(ans)

}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }



int main()
{
	int n;
	static ll a[114514];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	sort(a, a + n);


	ll res = 0;
	int tri = 0;
	for (int i = n - 1; i >= 2 && tri < 2; )
	{
		if (a[i - 1] + a[i - 2] > a[i])
		{
			res += a[i - 1] + a[i - 2] + a[i];
			++tri;
			i -= 3;
		}
		else
			--i;
	}
	if (tri < 2)
		res = 0;

	for (int i = n - 1; i >= 5; --i)
	{
		bool t[6];
		CL(t, 0);
		fill_n(t + 3, 3, true);
		do
		{
			ll x[3], y[3];
			int p = 0, q = 0;
			for (int j = 0; j < 6; ++j)
			{
				if (t[j])
					x[p++] = a[i - j];
				else
					y[q++] = a[i - j];
			}

			if (x[1] + x[2] > x[0] && y[1] + y[2] > y[0])
			{
				max_swap(res, accumulate(a + (i - 5), a + (i + 1), 0LL));
				goto End;
			}
		} while (next_permutation(t, t + 6));
	}
End:
	printf("%lld\n", res);
}

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

int main(){
  int A,B;
  cin>>A>>B;
  
  if(A==1){
     if(B!=1){
       cout<<"Alice"<<endl;
     }else{
       cout<<"Draw"<<endl;
     }
  }else if(B==1){
   cout<<"Bob"<<endl; 
  }else{
    if(A>B)cout<<"Alice"<<endl;
    else if(A<B)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),d=in();
    vector<vec> a(n,vec(d));
    rep(i,n){
        rep(j,d){
            a[i][j]=in();
        }
    }
    int ans=0;
    rep(i,n){
        rep2(j,i+1,n-1){
            ll tmp=0;
            rep(k,d){
                tmp+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            if((ll)sqrt(tmp)*(ll)sqrt(tmp)==tmp)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int H = 0;
		int W = 0;
		boolean flg = true;

		while ( true ) {
			H = sc.nextInt ();
			W = sc.nextInt ();

			if ( H == 0 && W == 0 ) {
				break;
			}
			
			for ( int i = 1; i <= H; i++ ) {
				if ( i % 2 == 0 ) {
					flg = false;
				} else {
					flg = true;
				}
				
				for ( int j = 1; j <= W; j++ ) {
					if ( flg == true ) {
						System.out.print ( "#" );
						flg = false;
					} else {
						System.out.print ( "." );
						flg = true;
					}
				}
				System.out.println ();
			}
			System.out.println ();
		}
	}
}

Measured memory_bytes: 34456
#include<bits/stdc++.h>
using namespace std;
int cnt;
void insertionSort(int *A,int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
void shellSort(int *A,int n){
  cnt=0;
  int r=1;
  vector<int> G;
  while(r<=n){
    G.push_back(r);
    r*=2;
  }
  int m=G.size();
  reverse(G.begin(),G.end());
  cout<<m<<endl;
  for(int i=0;i<m;i++) cout<<G[i]<<" \n"[i==m-1];
  for(int i=0;i<m;i++) insertionSort(A,n,G[i]);
  cout<<cnt<<endl;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  shellSort(A,n);
  for(int k=0;k<n;k++) cout<<A[k]<<endl;
  return 0;
}


Measured memory_bytes: 7024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int h,w;cin>>h>>w;
    vvch s(h,vch(w));
    rep(i,h)rep(j,w)cin>>s[i][j];
    vin dx={-1,0,0,1};
    vin dy={0,1,-1,0};
    bool tmp;
    int ni,nj;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#'){
            tmp=false;
            rep(k,4){
                ni=i+dy[k];
                nj=j+dx[k];
                if(-1<ni&&ni<h&&-1<nj&&nj<w&&s[ni][nj]=='#')tmp=true;
            }
            if(!tmp){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int cum[N], cum2[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    s = ' ' + s;
    for(int i = 1; i <= n; i++) cum[i] = cum[i - 1] + (s[i] == 'W');
    for(int i = n; i >= 0; i--) cum2[i] = cum2[i + 1] + (s[i] == 'R');
    int ans = mod;
    for(int i = 0; i <= n; i++){
        int kam_r = cum[i], kam_w = cum2[i + 1];
        int mn = min(kam_r, kam_w);
        int tmp = kam_r + kam_w - mn;
        // cout << i << ' ' << tmp << '\n';
        ans = min(ans, tmp);
    }
    cout << ans;

   return 0;
}


Measured memory_bytes: 5332
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
 
#define SENTINEL (1000000001)
#define putChar(c) ; *p = (char)(c); ++p;
 
int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500010];
char *p = str;
 
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
 
void putNum(int n) {
    int d;
    if (n < 10) {
        putChar( '0' + n );
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    putChar( '0' + (n % 10) );
}
 
void Merge(int A[], int left, int mid, int right) {
    int i = 0, j = 0, k = left;
    int n1 = mid - left;
    int n2 = right - mid;
    memcpy(L, A + left, n1 * sizeof(int));
    memcpy(R, A + mid, n2 * sizeof(int));
    L[n1] = R[n2] = SENTINEL;
    for (; k < right; ++k) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        } else {
            A[k] = R[j];
            ++j;
        }
    }
}
 
void MergeSort(int A[], int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) >> 1;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
        c += right - left;
    }
}
 
int main(void) {
    register int i;
    int n;
     
    fread(str, 1, 5500000, stdin);
    n = getNum();
    for (i = 0; i < n; ++i) {
        S[i] = getNum();
    }
     
    MergeSort(S, 0, n);
     
    --n;
    p = str;
    for (i = 0; i < n; ++i) {
        putNum(S[i]);
        putChar( ' ' );
    }
    putNum(S[i]);
    putChar( '\n' );
     
    putNum(c);
    putChar( '\0' );
     
    puts(str);
 
    return 0;
}

Measured memory_bytes: 10256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n;
	 cin>>n;
	 set<string>s;
	 string s1;
	 cin>>s1;
	 s.insert(s1);
	 for(int i=1;i<n;i++)
	 {
	   string s2;
	   cin>>s2;
	   if(s.count(s2)||s2[0]!=s1[s1.length()-1])
	   {
	   	printf("No\n");
	   	return 0;
	   }
	   	s.insert(s2);
	   	s1=s2;
	 }
	 printf("Yes\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
	ll a, b;
	cin >> a >> b;
	if (a > b)swap(a, b);
	REP(i, b)cout << a;
	cout << endl;
}


Measured memory_bytes: 256