akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int main()
{
	long long a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
	c-=a+b;
	if(c<0) printf("No");
	else if(c*c>4*a*b) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		double ans=0;
		for(int i = 0;i<n;i++) {
			ans+=1.0/a[i];
		}
		Console.WriteLine("{0}",1.0/ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





vector<pair<char, ll> > runlength(string str) {
    vector<pair<char, ll> > ret;
    int cnt = 1;
    int n = sz(str);
    rep3(i, 1, n) {
        if (str[i] == str[i - 1]) {
            cnt++;
        } else {
            ret.eb(make_pair(str[i - 1], cnt));
            cnt = 1;
        }
    }
    ret.eb(make_pair(str[n - 1], cnt));
    return ret;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    string s;
    cin >> s;
    ll k;
    cin >> k;
    
    auto run = runlength(s);
    if (s[0] != s[sz(s) - 1]) {
        ll ans = 0;
        rep(i, sz(run)) {
            ans += run[i].S / 2;
        }
        cout << ans * k << endl;
    } else {
        if (sz(run) == 1) {
            cout << (run[0].S * k) / 2 << endl; // ひとまとまり
        } else if (sz(run) == 2) {
            // ありえない
        } else {
            ll ans = (run[0].S + run[sz(run) - 1].S) / 2 * (k - 1);
            ans += run[0].S / 2;
            ans += run[sz(run) - 1].S / 2;
            rep3(i, 1, sz(run) - 1) {
                ans += run[i].S / 2 * k;
            }
            cout << ans << endl;
        }
    }
    
}


Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, x, t = input_a

tmp = (n / x.to_f).ceil
puts tmp * t


Measured memory_bytes: 14372
#include <cstdio>
#include <cctype>
#define il inline
#define rgi register int
#define sp putchar(' ')
#define el putchar('\n')
using namespace std;
il int ri()
{
	register int o1=0;
	register bool o2=0;
	register char o3;
	while(!isdigit(o3=getchar()))
		o2|=o3=='-';
	while(isdigit(o3))
		o1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();
	return o2?-o1:o1;
}
il void wi(int o1)
{
	if(o1<0)
		putchar('-'),o1=-o1;
	rgi o2=o1/10;
	if(o2)
		wi(o2);
	putchar((o1-(o2<<1)-(o2<<3))^48);
}
const int maxn=1e5+5;
int n,m,a[maxn],ans;
signed main()
{
	n=ri(),m=ri();
	for(rgi i=1;i<=n;++i)
		a[i]=ri();
	for(rgi i=1;i<=n;++i)
		if(a[i]>=m)
			++ans;
	wi(ans);
	return 0;
}


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

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> a(n,vector<int>(d));
	rep(i, n) rep(j, d)cin >> a[i][j];
	int ans = 0;
	rep(i, n)rep(j, i) {
		int sq = 0;
		rep(k, d) {
			int s = a[i][k] - a[j][k];
			sq += s * s;
		}
		int s = sqrt(sq);
		if (s * s == sq)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 03:09:14 2020

@author: Kanaru Sato
"""
import itertools as it

n = int(input())
l = []
for i in range(1,n+1):
    l.append(i)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

count = 0
for sequence in it.permutations(l,n):
    if list(sequence) == p:
        pnum = count
    if list(sequence) == q:
        qnum = count
    count += 1

print(abs(pnum-qnum))

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin >> x >> y;
    int d;
    if(x<y){
        if(y<=0 || x>=0) d=y-x;
        else d=abs(y+x)+1;
    }
    else{
        if(y>0 || x<0) d=2+x-y;
        else d=abs(-y-x)+1;
    }

    cout << d << "\n";
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var dp = new long[str.Length + 1, 4];
        var al = new[] { 'A', 'B', 'C' };
        dp[0, 0] = 1;
        for (var i = 1; i <= str.Length; i++)
        {
            for (var j = 0; j < 4; j++)
                dp[i, j] = (dp[i - 1, j] * (str[i-1] != '?' ? 1 : 3)) % Input.MOD;
            for (var j = 0; j < 3; j++)
                if (str[i-1] == '?' || str[i-1] == al[j])
                {
                    dp[i, j + 1] += dp[i - 1, j];
                    dp[i, j + 1] %= Input.MOD;
                }
        }
        WriteLine(dp[str.Length, 3]);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 14432
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let _n: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let h = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    let mut ans = 1;
    let mut max_h = h[0];
    for hi in h[1..].iter() {
        if *hi >= max_h {
            ans += 1;
        }
        max_h = std::cmp::max(*hi, max_h);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4476
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];

    let mut ans = 0i64;
    let mut tmp = 1i64;
    while tmp <= b {
        let mut count = 0;
        let am = a % (tmp * 2);
        let an = (a + tmp * 2) / (tmp * 2) * tmp * 2;
        let bm = b % (tmp * 2);
        let bn = b / (tmp * 2) * tmp * 2;
        if bn >= an {
            count += cmp::min(2 * tmp - am , tmp);
            count += (bn - an)/2;
            count += cmp::max(bm - tmp + 1, 0);
        } else {
            count = cmp::max(bm - cmp::max(am, tmp) + 1, 0);
        }
        ans += tmp * (count % 2);
        tmp *= 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long answer =0;
    long H[] = new long[N];
    for(int i=0;i<N;i++){
      H[i]=sc.nextLong();
    }
    if(N<=K){
      System.out.println(0);
      return;
    }
    Arrays.sort(H);
    for(int i=0;i<N-K;i++){
      answer = answer+H[i];
    }
    System.out.println(answer);
  }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	lli k;
	cin>>k;

	REP(i,0,s.size()){
		if(s.at(i)=='a')continue;
		lli use = 'z'-s.at(i)+1;
		if(use<=k){
			k-=use;
			s[i]='a';
		}
	}

	if(k>0){
		s[s.size()-1] += k%26;
	}
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
#define upd(X,Y) X=(X+Y)%MOD
typedef unsigned long long ull;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e6+3;
const ll maxn=1e5+7;
const int MAX=2e5+7;
const ll MOD=1e9+7;
const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
ll x;
int main()
{
//    freopen("out.txt","w",stdout);
    scanf("%lld",&x);
//    {
        ll n=50LL,t;
        t=x/n;
        ll yu=x%n;
        printf("%lld\n",n);
        ll xiao=t-yu+n-1LL;
//        ll da=n*(yu+1LL)+t-1LL;
        ll da=t-yu+2*n;
//        if(da>1e16+1000)
//            system("pause");
        for(int i=1;i<=n-yu;i++)
            printf("%lld ",xiao);
        for(int i=1;i<=yu;i++)
            printf("%lld ",da);
//    }
    return 0;
}
/*
499999999999999999
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n,m,c,ans=0;
    cin >> n >> m >> c;
    ll b[m];
    for (ll i=0;i<m;i++)cin >> b[i];
    for (ll i=0;i<n;i++){
        ll count=0;
        for (ll j=0;j<m;j++){
            ll a;
            cin >> a;
            count+=a*b[j];
        }
        if (count+c>0)ans++;
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
typedef long long ll;
using namespace std;

int x_class(int x) {
	return x % 10;
}

int main() {
	int a;
	cin >> a;
	int A = 0, B = 0, C = 0, D = 0;
	D = x_class(a);
	a /= 10;
	C = x_class(a);
	a /= 10;
	B = x_class(a);
	A = a / 10;
	
	if (A + B + C + D==7) {
		cout << to_string(A) + '+' + to_string(B) + '+' + to_string(C) + '+'  + to_string(D)+'='+'7' << endl;
		return 0;
    }
	if (A + B + C - D == 7) {
		cout << to_string(A) + '+' + to_string(B) + '+' + to_string(C) + '-' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
	if (A + B - C + D == 7) {
			cout << to_string(A) + '+' + to_string(B) + '-' + to_string(C) + '+' + to_string(D) + '=' + '7' << endl;
			return 0;
	}
	
	if (A + B - C - D == 7) {
		cout << to_string(A) + '+' + to_string(B) + '-' + to_string(C) + '-' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
	if (A - B + C + D == 7) {
		cout << to_string(A) + '-' + to_string(B) + '+' + to_string(C) + '+' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
	if (A - B + C - D == 7) {
		cout << to_string(A) + '-' + to_string(B) + '+' + to_string(C) + '-' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
	if (A - B - C + D == 7) {
		cout << to_string(A) + '-' + to_string(B) + '-' + to_string(C) + '+' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
	if (A - B - C - D == 7) {
		cout << to_string(A) + '-' + to_string(B) + '-' + to_string(C) + '-' + to_string(D) + '=' + '7' << endl;
		return 0;
	}
}

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

int main() {
	long long  a, b, c,d[10000],x;
	x = 0;

	cin >> a >> b >> c;

	for (a; a <=b; a++) {
		if (c%a == 0)
			x = x + 1;
		else
			x = x + 0;
	}
	cout << x << endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


typedef pair<int, string> p;

int main(){
  int n, m;
  cin >> n >> m;

  int d[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

  int a;
  vector<int> w(m);
  vector<p> v;
  REP (i, m) {
    cin >> a;
    w[i] = a;
  }
  sort(w.begin(), w.end(), greater<int>());

  REP (i, m) {
    if (d[w[i] - 1] % 2 == 0) v.push_back(make_pair(d[w[i] - 1], to_string(w[i])));
    else v.push_back(make_pair(d[w[i] - 1], to_string(w[i])));
  }

  string dp[n + 1] = {""};
  REP (i, n + 1) {
    REP (j, m) {
      int x = i - v[j].first;
      if (x > 0 && dp[x] == "") continue;
      if (x >= 0 && dp[x].size() >= dp[i].size()) dp[i] = dp[x] + v[j].second;
    }
  }
  string ans = dp[n];
  if (ans[0] - '0' < ans[ans.size() - 1] - '0') reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


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

typedef unsigned long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll mod = 998244353;
    ll n;
    cin >> n;
    vector<ll> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    sort(d.begin(), d.end());
    ll ans = 1;
    ll cur = 1;
    ll streak = 0;
    vector<ll> s;
    for (int i = 1; i < n; i++) {
        if (d[i] == cur) {
            streak++;
            if (i == n-1)
                s.push_back(streak);
        } else if (d[i] == cur + 1) {
            s.push_back(streak);
            cur++;
            streak = 1;
            if (i == n - 1)
                s.push_back(1);
        } else {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 1; i < s.size(); i++) {
        ll toAdd = 1;
        ll t = s[i - 1] % mod;
        for (int k = 0; k < s[i]; k++) {
            toAdd = toAdd % mod * (t % mod) % mod;
        }
        ans = (ans % mod) * (toAdd % mod) % mod;
    }
    cout << ans % mod << endl;
    return 0;
}


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

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) if (a[j] >> i & 1)++ x;
    ll now = x * (n - x) % mod;
    rep(j, i) now = now * 2 % mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

/*
#include <bits/stdc++.h>

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

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

  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) { cin >> A[i]; }

  ll ans = 0, now = 0;
  int x = 0;

  REP(i, 60) {
    x = 0;
    REP(j, N) {
      if (A[j] >> i & 1) {
        ++x;
      }
    }
    now = x * (N - x) % MOD;
    REP(j, i) { now = now * 2 % MOD; }
    ans = ans + now;
    ans = ans % MOD;
  }

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

Measured memory_bytes: 2560
int main(){
    int h,w,a=0;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0){
            break;
        }else{
            for(int i=w;i>0;i--){
                putchar('#');
            }
            putchar('\n');
            for(;h>2;h--){
                putchar('#');
            for(int i=w;i>2;i--){
                putchar('.');
            }
            printf("#\n");
        }
        for(int i=w;i>0;i--){
                putchar('#');
            }
        printf("\n\n");
        }
    }
}


Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
char grid[256][256];

int solve(){
  int res = 0, c;
  rep(i, n){
    c = 0;
    rep(j, n){
      if(grid[i][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(j, n){
    c = 0;
    rep(i, n){
      if(grid[i][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(i - j < 0) break;
      if(grid[j][i-j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(n-j < 0 || n-i+j-1 >= n || n-i+j-1 < 0) break;
      if(grid[n-i+j-1][n-j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(n - i + j - 1>= n) break;
      if(grid[j][n-i+j-1] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(i + j >= n) break;
      if(grid[i+j][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  return res;
}

int main(){
  while(scanf("%d", &n) && n){
    memset(grid, 0, sizeof(grid));
    rep(i, n) scanf("%s", grid[i]);
    printf("%d\n", solve());
  }
  return 0;
}

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

int main()
{
    int K;
    string S;
    cin >> K >> S;

    if (S.size() <= K)
    {
        cout << S;
    }

    else
    {
        int as = S.size();
        for (int i = 0; i < as-K; i++)
        {
            S.pop_back();
        }

        cout << S << "...";
        
    }
    
    
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> f(H);
    rep(i,H) cin >> f[i];
    int ans=0;
    rep(i,H) rep(j,W){
        if (f[i][j]=='#') continue;
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<Pii> que;
        que.emplace(i,j);
        d[i][j]=0;
        int dh[4]={1,0,-1,0},dw[4]={0,1,0,-1};
        while(!que.empty()){
            Pii p=que.front(); que.pop();
            int h=p.first,w=p.second;
            rep(rot,4){
                int nh=h+dh[rot],nw=w+dw[rot];
                if (nh<0||nh>=H||nw<0||nw>=W) continue;
                if (f[nh][nw]=='#') continue;
                if (d[nh][nw]>=0) continue;
                d[nh][nw]=d[h][w]+1;
                chmax(ans,d[nh][nw]);
                que.emplace(nh,nw);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
long long sum[200005];
int x[200005];
int n;
int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++) {scanf("%d",&a[i]);sum[i] = sum[i - 1] + a[i];x[i] = x[i - 1] ^ a[i];}
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        int l = i , r = n;
        while(l < r){
            int mid = ((l + r) >> 1) + 1;
            if((sum[mid] - sum[i - 1]) > (x[mid] ^ x[i - 1])) r = mid - 1;
            else l = mid;
        }
        ans += (l - i + 1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s0(n), s1(n);
    string t;
    for (int i = 0; i < n; i++) {
        cin >> s0[i];
        s1[i] = s0[i];
        int k = (int)s0[i].size();
        for (int j = 0; j < k; j++) {
            if (s0[i][j] == '?') {
                s0[i][j] = 'z';
                s1[i][j] = 'a';
            }
        }
    }
    cin >> t;
    sort(s0.begin(), s0.end());
    sort(s1.begin(), s1.end());
    int t0 = lower_bound(s0.begin(), s0.end(), t) - s0.begin();
    int t1 = upper_bound(s1.begin(), s1.end(), t) - s1.begin();
    for (int i = t0; i <= t1; i++) {
        cout << i + 1 << " \n"[i == t1];
    }

    return 0;
}

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

int grid[50][50];
int n, m;

bool check(int y) {
    int win = 0, draw = 0;
    for (int x = 0; x < n; x++) {
        if (y == x) continue;
        if (grid[y][x] == 1) win++;
        if (grid[y][x] == 0) draw++;
    }
    return win <= (n - 1) / 2 && win + draw >= (n - 1) / 2;
}

ll ans;
void dfs(int cur) {
    int x = cur % n;
    int y = cur / n;
    if (cur == n * n) {
        ans++;
        return;
    }
    // 自分自身 or 既に埋まってる
    if (y == x || grid[y][x] != 0) {
        if (check(y)) dfs(cur + 1);
        return;
    }
    grid[y][x] = 1;
    grid[x][y] = -1;
    if (check(y)) dfs(cur + 1);
    grid[y][x] = -1;
    grid[x][y] = 1;
    if (check(y)) dfs(cur + 1);
    grid[y][x] = grid[x][y] = 0;
}

int main() {
    while (cin >> n, n) {
        cin >> m;
        memset(grid, 0, sizeof(grid));
        for (int i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            grid[x][y] = 1;
            grid[y][x] = -1;
        }
        ans = 0;
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3060
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] strInput = Console.ReadLine().Split(' '); ;
		int[] x = new int[5];

		for(int i = 0; i < 5; i++)
		{
			x[i] = int.Parse(strInput[i]);
			if (x[i] == 0)
			{
				Console.WriteLine(i + 1);
				return;
			}
		}
		
		return;
	}
}

Measured memory_bytes: 27536
import math


A, B, H, M = map(int, input().split())
b = 360 * M / 60
a = (H * 60 + M) * 360 / (12 * 60)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(b - a))) ** .5)

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

 
int main() {
	
ll X;
cin>>X;

if(X%11>6){
	ce(X/11*2+2)
}else if(X%11!=0){
	ce(X/11*2+1)
}else{
	ce(X/11*2)
}
	
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	if A == 1 {
		A = 14
	}
	if B == 1 {
		B = 14
	}

	if A == B {
		fmt.Println("Draw")
	} else if A > B {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.stream.*;
import java.util.Arrays;
  
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      final int n = sc.nextInt();
      if ( n == 0 )break;
      int max = sc.nextInt();
      int min = max;
      int sum = max;
      for( int i=1; i<n; ++i ){
        int s = sc.nextInt();
        if ( max < s ){ max = s; }
        if ( s < min ){ min = s; }
        sum += s;
      }
      System.out.println( (sum-max-min)/(n-2) );
    }
  }
  
}


Measured memory_bytes: 29024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
    ll n;
    ll x[1010];
    cin>>n;
    rep(i,n) cin>>x[i];
    ll ans=LLINF;
    rep(i,101){
        ll sum=0;
        rep(j,n){
            sum+=(x[j]-i)*(x[j]-i);
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>

int main(void){
  int x , y;
  scanf("%d %d",&x ,&y);


  int flag = 0;
  for(int i = 0;i <= x;i ++){
    int t = x - i;
    if(i*2 + t*4 == y){
      flag  ++;
      i += x+1;
    }
  }

  if(flag != 0){
    printf("Yes\n");
  }

  else{
    printf("No\n");
  }
  return 0;
}

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


//ABC 114 c

vector<char> lis = {'3','5','7'};
int dfs(string S,ll n){
    int res = 0;

    if(S.size()>0){
        if(stoll(S) > n) return res;
        bool flag = true;
        for(auto c : lis){
            if(S.find(c) == string::npos) flag = false;
        }
        if(flag) res++;
    }

    for(auto c : lis){
        S.push_back(c);
        res += dfs(S,n);
        S.pop_back();
    }

    return res;
}


int main(){
    ll n;
    cin >> n;
    string s = "";
    int count = dfs(s,n);
    cout << count << endl;
}




Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int N, x, a[100000], count = 0;
	cin >> N >> x;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < N; i++) {
		if (a[i - 1] > x) {
			count += a[i - 1] + a[i] - x;
			a[i] = 0;
		}
		else if (a[i - 1] + a[i] > x) {
			count += a[i - 1] + a[i] - x;
			a[i] = x - a[i - 1];
		}
	}
	cout << count;
}

Measured memory_bytes: 1024
L = str(input())
mod = 10 ** 9 + 7

#a + b = a xor b を満たすのは a, b の bit が一つも被っていないとき
ans = 1
three = [1] * (len(L) + 1)
for i in range(len(L)):
  ans *= 3
  ans %= mod
  three[i + 1] = ans
  
#print(three)
x = 1
for i in range(len(L)):
  if L[i] == "0":
    y = x * 2
    #print(three[len(L) - i - 1], y, i)
    y *= three[len(L) - i - 1]
    #print(y)
    #y %= mod
    ans -= y
    ans %= mod
  else:
    x *= 2
    x %= mod
    
print(ans)    




Measured memory_bytes: 12728
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll p, q, r;
  cin >> p >> q >> r;
  ll a = p + q;
  ll b = q + r;
  ll c = r + p;
  chmin(a, b);
  chmin(a, c);
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


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

int main(void) {
    int n, ma, mb, i, j, k, a[43], b[43], c[43], dp[43][403][403] = {}, ans;
    const int INF = 1e9;

    cin >> n >> ma >> mb;
    for (i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (i = 0; i <= n; i++) for (j = 0; j <= 400; j++) for (k = 0; k <= 400; k++) {
        dp[i][j][k] = INF;
    }

    dp[0][0][0] = 0;

    for (i = 1; i <= n; i++) {
        for (j = 0; j <= 400; j++) for (k = 0; k <= 400; k++) {
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
            if (j >= a[i - 1] && k >= b[i - 1]) {
                dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
            }
        }
    }

    i = 1;
    ans = 1e9;
    while (ma * i <= 400 && mb * i <= 400) {
        ans = min(ans, dp[n][ma * i][mb * i]);
        i++;
    }

    if (ans == 1e9) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 27520
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        A: [u128; N],
    }

    let zero = A.iter().filter(|&&a| a == 0).count();

    if zero > 0 {
        println!("0");
        return;
    }

    let mut prd = 1;
    let mx = 1000000000000000000;
    for &a in &A {
        prd *= a;
        if prd > mx {
            println!("-1");
            return;
        }
    }
    println!("{}", prd);
}


Measured memory_bytes: 5336
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B, N = map(int, input().split())
    x = max(1, min(B - 1, N))
    print((A * x) // B - A * (x // B))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
void solve()
{	
	int x, a;
	cin >> x >> a;
	if(x >= a) cout << 1;
	cout << 0;
 
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
// Peaks

func main() {
    let nm = readLine()!.split(separator: " ").map{Int($0)!}
    let h = ("0 " + readLine()!).split(separator: " ").map{Int($0)!}
    var flugs: [Bool] = Array(repeating: true, count: nm[0] + 1)
    flugs[0] = false
    for _ in 0..<nm[1] {
        let aibi = readLine()!.split(separator: " ").map{Int($0)!}
        let ai = aibi[0]
        let bi = aibi[1]
        let ha = h[ai]
        let hb = h[bi]
        if ha == hb {
            flugs[ai] = false
            flugs[bi] = false
        } else if ha > hb {
            flugs[bi] = false
        } else {
            flugs[ai] = false
        }
    }
    print(flugs.filter{$0}.count.description)
}

main()

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

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

    int n,p,ans=0,mi=1001001;
    cin >> n;
    rep(i,0,n){
    	cin >> p;
    	if(mi>p)ans++;
    	mi = min(mi,p);
    }
    cout << ans << "\n";

}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int X;
  cin >> X;

  int ans=1;
  int p=2;
  int i_max=32;
  while(2<i_max){
    for(int i=2;i<i_max;++i){
      int temp=pow(i,p);
      if(X<temp){
	i_max=i;
	break;
      }
      ans=max(ans,temp);
    }
    ++p;
  }

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


Measured memory_bytes: 4020
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    n;
  char    **s;
  answer = 0;
  scan = scanf("%lld", &n);
  s = (char **)malloc(sizeof(char *) * n);
  for (ll j = 0; j < n; j++) {
    s[j] = (char *)malloc(sizeof(char) * 4);
  }
  for (ll i = 0; i < n; i++) {
    scan = scanf("%s", s[i]);
  }

  /* プログラムを書く */
  ll  ac = 0;
  ll  wa = 0;
  ll  tle = 0;
  ll  re = 0;

  for (ll k = 0; k < n; k++) {
    if (s[k][0] == 'A' && s[k][1] == 'C')
      ac++;
    if (s[k][0] == 'W' && s[k][1] == 'A')
      wa++;
    if (s[k][0] == 'T' && s[k][1] == 'L' && s[k][2] == 'E')
      tle++;
    if (s[k][0] == 'R' && s[k][1] == 'E')
      re++;
  }
    
  /* 文回答 */
  printf("AC x %lld\n", ac);
  printf("WA x %lld\n", wa);
  printf("TLE x %lld\n", tle);
  printf("RE x %lld\n", re);

  return (0);
}



Measured memory_bytes: 5580
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int N;
vc C;

void dfs(int n, char mx, string res) {
  if (n >= N) {
    printf("%s\n", res.c_str());
    return;
  }

  mx = max(mx, res[n-1]);
  
  for (int i = 0; i < C.size(); i++) {
    if (mx + 1 < C[i]) break;
    
    dfs(n+1, mx, res + C[i]);
  }
}

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

  cin>>N;

  REP(i, N) {
    C.push_back((char)('a'+i));
  }
  dfs(1, 'a', "a");
  

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , l ;
  	cin >> n >> l ;
  	int tot = n*l + (n*(n-1))/2 ;
  	int mn = 100000000, ans  ;
  	for(int i = 1 ; i <= n ; i++){
  		if(mn > abs(l + i - 1)){
  			mn = abs(l + i - 1) ;
  			ans = l + i - 1 ;
  		}
      //mn = min(mn , abs(l + i - 1));
    }
    // cout << ans << '\n';
  	cout << tot - ans ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    int N,W;
    cin >> N >> W;
    vector<ll> w(N+1);vector<int> v(N+1);
    rep(i,N)cin >> w[i+1] >> v[i+1];
    Graf dp(N+1,vector<ll>(100010));

    rep(i,100010)dp[0][i]=MAX;
    dp[0][0]=0;

    for(int i=1;i<=N;++i){
        for(int j=1;j<100010;++j){
            if(j>=v[i])
                dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    int ans=100009;
    while(dp[N][ans]>W){
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 83248
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;






int main() {
    
    int n;
    cin>>n;
    vi ans(n+1,0);
    for(int x=1;x<=101;x++){
        for(int y=1;y<=101;y++){
            for(int z=1;z<=101;z++){
                int t=x*x + y*y + z*z + x*y + x*z + y*z;
                if(t<ans.size())ans[t]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
}



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

int main(){
  int N,M;
  cin >> N >> M;
  int ans=0;
  vector<vector<int>> Connect(0);
  for(int i=0;i<M;i++){
    vector<int> vec(0,0);
    int K;
    cin >> K;
    for(int j=0;j<K;j++){
      int s;
      cin >> s;
      vec.push_back(s);
    }
    Connect.push_back(vec);
  }
  vector<int> P(0);
  for(int i=0;i<M;i++){
    int p;
    cin >> p;
    P.push_back(p);
  }
  for(int bit=0; bit < (1<<N); bit++){
    for(int i=0;i<M;i++){
      int count=0;
      for(int j=0;j<Connect[i].size();j++){
        if (bit & (1<<(Connect[i][j]-1))) count++;
      }
      if(count%2 != P[i]) break;
      if(i == M-1) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

A = []
n = int(input())

for _ in range(n):
    command = input()
    if command == "2":
        A.pop()
    else:
        command, value = command.split()
        if command == "0":
            A.append(int(value))
        else:
            print(A[int(value)])


Measured memory_bytes: 13352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, -1};
int dy[4] = {1, -1};

int func(char a) {
  if (a <= 90)
    return a - 65;
  else
    return (a - 97) + 26;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl DP(N, 0);
  vl A(53, 0);
  vector<string> S(2);
  queue<char> Q;
  REP(i, 2) cin >> S[i];

  REP(i, N) {
    if (i == 0) {
      if (S[0][i] == S[1][i])
        DP[i] = 3;
      else
        DP[i] = 6;
    } else if (S[0][i] == S[0][i - 1])
      DP[i] = DP[i - 1];
    else if (S[0][i] == S[1][i]) {
      if (S[0][i - 1] == S[1][i - 1])
        DP[i] = (DP[i - 1] * 2) % MOD;
      else
        DP[i] = DP[i - 1];
    } else {
      if (S[0][i - 1] == S[1][i - 1])
        DP[i] = (DP[i - 1] * 2) % MOD;
      else
        DP[i] = (DP[i - 1] * 3) % MOD;
    }
  }

  cout << DP[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
    int n, b, f, r, v;
    int arr[4][3][10];
    scanf("%d",&n);
    for(b=0;b<4;b++)
        for(f=0;f<3;f++)
            for(r=0;r<10;r++)
                arr[b][f][r] = 0;
    while(n--){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        arr[b-1][f-1][r-1] += v;
    }
    for(b=0;b<4;b++){
        for(f=0;f<3;f++){
            for(r=0;r<10;r++){
                printf(" %d", arr[b][f][r]);
            }
            printf("\n");
        }
        if(b!=3)
        printf("####################\n");
    }
return 0;
}



Measured memory_bytes: 2112