akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    for (int i = i; i < N; i++) {
        string X = S.substr(0, i);
        string Y = S.substr(i);
        set<char> s1, s2;
        for (char& ch : X) {
            s1.insert(ch);
        }
        for (char& ch : Y) {
            s2.insert(ch);
        }
        set<char> s;
        set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
            inserter(s, s.begin()));
        ans = max<int>(ans, s.size());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100000
#define NIL -1
struct Node {
  int parent;
  int left;
  int right;
};

struct Node T[MAX];

int getDepth(int u){
  int d=0;
  while(T[u].parent!=NIL){
    u=T[u].parent;
    d++;
  }
  return d;
}

void printChildren(int u,int d){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",d);
  if(T[u].parent==NIL) printf("root, ");
  else if(T[u].left==NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int main(){
  int i,u,n;
  int d,j,c,l,v,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	T[v].left=c;
      }
      else{
	T[l].right=c;
      }
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL) r=i;
  }


  for(i=0;i<n;i++){
    u=getDepth(i);
    printChildren(i,u);
  }
  return 0;
}



Measured memory_bytes: 2968
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    
    return result
        
X, Y = map(int, input().split(' '))
a = -1
b = -1
    
if (2*Y-X)%3 == 0 and (2*X-Y)%3 == 0:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    
    
    
if a < 0 or b < 0:
    ans = 0
else:
    ans = cmb(a+b, b)
print(ans % 1000000007)

Measured memory_bytes: 44028
#include <iostream>

using namespace std;

int main(){
  while(true){
    int n,p,i,wan;
    cin >> n >> p;
    if (n==0&&p==0)
      break;
    wan = p;
    int people[n];
    for(int j=0;j<n;j++)
      people[j] = 0;
    for(i=0;;i++){
      if (wan > 0){
	people[i%n]++;
	wan--;
	if (people[i%n] == p)
	  break;
      }
      else{
	wan += people[i%n];
	people[i%n] = 0;
      }
    }
    cout << i%n << endl;
  }
  return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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

int dtm(int d){
  if(d < 22 || 99 < d || d%10 < 2)return -1;
  int d1 = d%10;
  int d10 = (d - d1)/10;
  return d1*d10;
}

int main(){
  int m,d;cin >> m >> d;
  int cnt = 0;
  for(int i = 1; i <= d; ++i){
    int x = dtm(i);
    if(x >= 1 && x <= m)cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def submit():
    s = input().strip()
    t = input().strip()

    # 変換ペアを作成した際に
    # 変換先/変換元が重複していなければOK
    check_s = {}
    check_t = {}
    for se, te in zip(s, t):
        if se in check_s.keys() and check_s[se] != te:
            print("No")
            return
        else:
            check_s[se] = te
        
        if te in check_t.keys() and check_t[te] != se:
            print("No")
            return
        else:
            check_t[te] = se
        
    print("Yes")


if __name__ == "__main__":
    submit()
                


Measured memory_bytes: 3632
_, K = map(int, input().split())
S = input()

offset = not (int(S[0]) ^ (K & 1))
runs = []

prev = S[0]
run = 0
for c in S:
    if c != prev:
        runs.append(run)
        run = 0
    prev = c
    run += 1
runs.append(run)

L = len(runs)
candidates = []

prev = sum(runs[max(0, offset - K): min(L, offset + K + 1)])
answer = prev

for i in range(offset + 2, L, 2):
    now = prev
    old_left = i - 2 - K
    new_right = i + K
    if old_left >= 0:
        now -= runs[old_left]
    if old_left + 1 >= 0:
        now -= runs[old_left + 1]
    if new_right - 1 < L:
        now += runs[new_right - 1]
    if new_right < L:
        now += runs[new_right]
    prev = now
    if prev > answer:
        answer = prev

print(answer)


Measured memory_bytes: 45680
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            double N;double M;
            Multi(out N, out M);

            var ans = ((N - M) * 100 + 1900 * M) * Math.Pow(2, M);

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13140
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    if a <= 8 && b <= 8 {
        "Yay!".to_string()
    } else {
        ":(".to_string()
    }
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	bool cnt[150][150];
	for (int i = 0; i < 150; i++) {
		for (int j = 0; j < 150; j++) {
			cnt[i][j] = false;
		}
	}
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		for (int j = 0; j < A; j++) {
			cnt[i][j] = true;
		}
	}
	int ret = 0;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < N; j++) {
			if (j == 0) {
				if (cnt[j][i] == true) {
					ret++;
				}
			}
			else {
				if (cnt[j - 1][i] == false && cnt[j][i] == true) {
					ret++;
				}
			}
		}
	}
	cout << ret << endl;
}

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

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    rep(i, 3){
        if (X == 3) {
            cout << "YES" << endl;
            return 0;
        }
    X-= 2;
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
# zipを使用する版

H, W = map(int, input().split())
a = []
for _ in range(H):
    tmp = list(input())
    if "#" in tmp:
        a.append(tmp)

a_reverse = list(map(list, zip(*a)))
ans = []
for tmp in a_reverse:
    if "#" in tmp:
        ans.append(tmp)

ans_list = list(map(list, zip(*ans)))

for tmp_list in ans_list:
    tmp = ""
    for tmp_val in tmp_list:
        tmp += tmp_val
    print(tmp)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    string S;
    cin >> S;
    int count_one=0;
    int count_zero=0;
    RANGE(i,S.size()){
      if(S.at(i)=='1')count_one += 1;
      else count_zero += 1;
    }
    int n_remove = min(count_one, count_zero) * 2;
    cout << n_remove << endl;
}


Measured memory_bytes: 512
N,K = map(int,input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int,input().split()))

ans = max(C)
for i in range(N):
    s = i
    l = [C[i]]
    while True:
        s = P[s]
        if s == i:
            break
        l.append(C[s])
        

    if sum(l) > 0:
        if K>=len(l):
            c = (K//len(l)-1)*sum(l)
            n = K%len(l)+len(l)
        else:
            c = 0
            n = K
        ans = max(ans,c)
        s = i
        for j in range(n):
            c += C[s]
            s = P[s]
            ans = max(ans,c)

    n = min(N,K)
    s = i
    c = 0
    for j in range(n):
        c += C[s]
        s = P[s]
        ans = max(ans,c)
            
print(ans)

Measured memory_bytes: 78224
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e5+10;
int n,a[N],b[N],res;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i]>>b[i];
	sort(a+1,a+1+n),sort(b+1,b+1+n);
	if(n&1)	res=b[n/2+1]-a[n/2+1]+1;
	else res=b[n/2+1]+b[n/2]-a[n/2+1]-a[n/2]+1;
	cout<<res;
	return 0;
}


Measured memory_bytes: 5180
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int sum[2001][2001];
ll f(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int k;cin>>k;
    int n=s.size();
    ll dp[n+1][5][2];
    memset(dp,0,sizeof dp);
    dp[0][0][0]=1;
    rep(i,0,n){
        rep(j,0,4){
            if(s[i]-'0'==0){
                dp[i+1][j][0]+=dp[i][j][0];
                dp[i+1][j][1]+=dp[i][j][1];
                dp[i+1][j+1][1]+=dp[i][j][1]*9;
            }
            else{
                int u=s[i]-'0';
                dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
                dp[i+1][j+1][0]+=dp[i][j][0];
                dp[i+1][j+1][1]+=dp[i][j][0]*(u-1)+dp[i][j][1]*9;
            }
        }
    }
    cout<<dp[n][k][0]+dp[n][k][1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, q;
    cin>>n;
    LL c[MX] = {0}, sum = 0, a;
    loop(i,0,n) {cin>>a; ++c[a]; sum += a;}

    cin>>q;
    LL x, y;
    loop(i,0,q)
    {
        cin>>x>>y;
        sum -= (c[x] * x);
        sum += (c[x] * y);
        c[y] += c[x];
        c[x] = 0;
        cout<<sum<<'\n';
    }

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N;
    cin >> M;
    string a[1000];
    for(int i = 0; i < N;i++){

        cin >> a[i];
    }
    for(int i = 0; i < M + 2;i++)
    cout << "#";
    cout << endl;
    for(int i = 0;i < N;i++){
        cout << "#" << a[i] <<"#"<<endl;
    }
    for(int i = 0; i < M + 2;i++)
    cout << "#";
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n,a;
    cin>>n>>a;
    if(n>a)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;

    return 0;
}

Measured memory_bytes: 3632
N = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(N):
    a, b, c = map(int, input().split())
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(1, N+1):
    dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    time = t[i] - t[i-1]
    # print(time, dist)
    if time >= dist and (dist - time) % 2 == 0:
        continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 11736
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<LLONG> as(N); for (auto &ai : as) cin >> ai;
    cout << accumulate(as.begin(), as.end(), 0LL) - N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
using namespace std;
typedef long long ll;
ll x,y;
int main(){
	cin>>x>>y;
	if(x<y)swap(x,y);
	if(x-y <= 1)puts("Brown");
	else puts("Alice");
}

Measured memory_bytes: 256
unittest
{
	assert( [ "B" ].solve == "A" );
	assert( [ "a" ].solve == "a" );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	
	if( 'A' <= s.front && s.front <= 'Z' ) return "A";
	else                                   return "a";
}


Measured memory_bytes: 2752
// 2017/05/19 Tazoe

#include <iostream>
using namespace std;

// Node?????????
class Node{
public:
	Node* prev;	// ?????????????????????????????????
	Node* next;	// ?¬???????????????????????????????
	int data;	// ?????????
	Node(){prev = 0; next = 0; data = 0;}		// ????????????????????????????????????
};

// List?????????
class List{
private:
	Node head;	// ?????????????????????????????????
public:
	List(){head.prev = &head; head.next = &head;}	// ????????????????????????????????????
	int insert(int x);		// ?????\
	int del(int x);			// ??????
	int deleteFirst();		// ???????????????
	int deleteLast();		// ????°??????????
	void print();			// ??¨???
};

// insert????????????????????\???
int List::insert(int x)
{
	Node* p = new Node();

	if(p==0)
		return -1;		// ?????¢????¢??????¨??????

	Node* q = &head;
	Node* r = head.next;

	p->prev = q;
	p->next = r;
	p->data = x;

	q->next = p;
	r->prev = p;

	return 0;			// ??£?????????
}

// del????????????????????????
int List::del(int x)
{
	Node* p;

	for(p=head.next; p!=&head; p=p->next){
		if(p->data==x)
			break;
	}

	if(p==&head)
		return -2;		// ??¢?´¢??¨??????

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// ??£?????????
}

// deleteFirst?????????????????????????????????
int List::deleteFirst()
{
	Node* p = head.next;

	if(p==&head)
		return -2;		// ??¨??????

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// ??£?????????
}

// deleteLast???????????????????°?????????????
int List::deleteLast()
{
	Node* p = head.prev;

	if(p==&head)
		return -2;		// ??¨??????

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// ??£?????????
}

// print?????????????????¨??????
void List::print()
{
	for(Node* p=head.next; p!=&head; p=p->next){
		cout << p->data;

		if(p->next!=&head){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
}


// main??¢??°
int main()
{
	List L;

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		char com[20];		// C?????????
		cin >> com;

		if(com[0]=='i'){
			int x;
			cin >> x;

			L.insert(x);
		}
		else if(com[6]=='F'){
			L.deleteFirst();
		}
		else if(com[6]=='L'){
			L.deleteLast();
		}
		else{
			int x;
			cin >> x;

			L.del(x);
		}
	}

	L.print();

	return 0;
}

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

int n;
long long c;
vector <long long> x, v, sum, macs, dist;
const long long INF = 1e18;

int main() {
	cin >> n >> c;
	x = v = vector <long long> (n);
	rep (i, n) cin >> x[i] >> v[i];

	long long ans = 0;
	rep (cnt, 2) {
		dist = sum = macs = vector <long long> (n + 1, 0);
		long long tmpMax = -INF, tmpDist = 0;
		rep (i, n) {
			sum[i + 1] += sum[i] + v[i];
			if (tmpMax < sum[i + 1] - x[i]) {
				tmpMax = max(tmpMax, sum[i + 1] - x[i]);
				tmpDist = x[i];
			}
			dist[i + 1] = tmpDist;
			macs[i + 1] = tmpMax;
		}

		long long nowSum = 0;
		rep (i, n + 1) {
			if (!i) {
				ans = max(ans, macs[n]);
				continue;
			}
			nowSum += v[n - i];
			ans = max({ans,
					   nowSum - c + x[n - i],
					   nowSum + macs[n - i] - (c - x[n - i]) * 2});
		}

		reverse(v.begin(), v.end());
		reverse(x.begin(), x.end());
		for (auto& i: x) i = c - i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        int cnt = 0;

        int n = scan.nextInt();
        int[] array = new int[n];
        for(int i=0; i<n; i++){
            array[i] = scan.nextInt();
        }
        boolean flg = true;
        while(flg){
            for(int i=0; i<n; i++){
                if(array[i]%2==0) array[i] /= 2;
                else{
                    flg = false;
                    break;
                }
            }
            if(flg) cnt++;
        }

        scan.close();
        System.out.println(cnt);
    }
}

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

map<int, set<int>> routes;

int ans = 0;
int N;

int search(int position, vector<bool> reached)
{
    bool all_visited = true;
    rep(i, N)
    {
        if (reached.at(i) == false)
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }

    int ret = 0;

    for (int next_position : routes[position])
    {
        if (reached.at(next_position))
        {
            continue;
        }
        reached.at(next_position) = true;
        ret += search(next_position, reached);
        reached.at(next_position) = false;
    }

    return ret;
}

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

    vector<int> a(M);
    vector<int> b(M);
    rep(i, M) cin >> a.at(i) >> b.at(i);
    rep(i, M)
    {
        a.at(i)--;
        b.at(i)--;
    }

    rep(i, M)
    {
        routes[a.at(i)].insert(b.at(i));
        routes[b.at(i)].insert(a.at(i));
    }
    vector<bool> reached(N, false);
    reached.at(0) = true;
    
    cout << search(0, reached) << endl;

    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    cin >> N;
    Vl A(N + 1);
    for (ll i = 1; i <= N; i++) {
        cin >> A[i];
    }

    Vl ans(N + 1);
    for (ll i = N; i >= 1; i--) {
        ll s = 0;
        for (ll j = i + i; j <= N; j += i) {
            s += ans[j];
        }
        s %= 2;
        if (s == A[i]) {
            ans[i] = 0;
        }
        else {
            ans[i] = 1;
        }
    }

    ll num = accumulate(ans.begin(), ans.end(), 0LL);
    cout << num << "\n";

    if (num > 0) {
        for (ll i = 1; i <= N - 1; i++) {
            if (ans[i] == 1)
                cout << i << " ";
        }
        if (ans[N] == 1) {
            cout << N << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
 
typedef struct node * Node;
 
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
 
  while(x->left != NIL){
    x = x->left;
  }
  return x;
 
}
 
Node treeSearch(Node u, int k){
 
  if(u == NIL || k == u->key){
    return u;
  }
 
  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right,k);
  }
 
}
 
Node treeSuccessor(Node x){
 
  Node y;
 
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
 
  y = x->parent;
 
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  //
  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else{
    y = treeSuccessor(z);
  }
 
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }
 
  if(x != NIL){
    x->parent = y->parent;
  }
 
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left = x;
  }
  else{
    y->parent->right = x;
  }
 
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  //
 
  while(x != NIL){
    y = x;
 
    if(k < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
 
  z->parent = y;
   
  if(y == NIL){
    root = z;
  }
  else if(k < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
   
}
 
void inorder(Node u){
 
  if(u->left != NIL ){
    inorder(u->left);
    printf(" %d", u->key);
  }
  else{
    printf(" %d", u->key);
  }
 
  if(u->right != NIL){
    inorder(u->right);
  }
   
}
  
void preorder(Node u){
   
  printf(" %d", u->key);
   
  if(u->left != NIL){
    preorder(u->left);
  }
   
  if(u->right != NIL){
    preorder(u->right);
  }
   
}
 
 
int main(){
  int n, i, x;
  char com[20];
   
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
     
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       
      Node t = treeSearch(root, x);
       
      if ( t != NIL ){
    printf("yes\n");
      }
      else{
    printf("no\n");
      }
       
    }
     
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
     
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
       
      preorder(root);
      printf("\n");
    }
     
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
     
  }
   
  return 0;
}

Measured memory_bytes: 19364
import java.util.Scanner;

public class Main {

    static double[][] dp;

    static double calculate(double[] arr, int count, int pos){
        if(count == 0)
            return 1;
        if(pos >= arr.length)
            return 0;
        if(dp[count][pos] != -1)
            return dp[count][pos];

        dp[count][pos] = (1-arr[pos])*calculate(arr,count,pos+1) + (arr[pos]*calculate(arr,count-1,pos+1));

        return dp[count][pos];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int heads = (n/2);
        double[] arr = new double[n];
        dp = new double[n+1][n+1];

        for(int i  =0; i < n+1; i ++){
            for (int j =0; j < n+1; j++){
                dp[i][j] = -1;
            }
        }

        for(int i=0; i < n; i++){
            arr[i] = sc.nextDouble();
        }

        double ans = 0;

//        for(int i =  heads+1 ; i <= n; i++){
//            ans += calculate(arr,i,0);
//        }

        System.out.println(calculate(arr,heads+1,0));
    }
}


Measured memory_bytes: 134656
using namespace std;
#include <vector>
#include <cstdio>
#include <cmath>

int main(){
  int N, a0, b0, c0, a1, b1, c1;
  scanf("%d %d %d %d", &N, &a0, &b0, &c0);

  for(int i=1; i<N; i++){
    scanf("%d %d %d", &a1, &b1, &c1);
    a1 += max(b0, c0);
    b1 += max(a0, c0);
    c1 += max(b0, a0);
    a0=a1; b0=b1; c0=c1;
  }
  printf("%d\n", max(max(a0, b0), c0));
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int N;
int a[3][100010];
int main() {
	scanf("%d",&N);
	for (int j = 0; j < 3;j++) {
		for (int i = 0; i < N; i++) {
			scanf("%d", &a[j][i]);
		}
		sort(a[j], &a[j][N]);
	}
	LL ans = 0;
	for (int i = 0; i < N;i++) {
		ans += (lower_bound(a[0], a[0] + N, a[1][i]) - a[0]) * (a[2]+N-upper_bound(a[2],a[2]+N,a[1][i]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;

void solve(){
    char c[1005];
    scanf("%s",c);
    printf("%s",c);
    int len=strlen(c);
    if(c[len-1]=='s')printf("e");
    printf("s\n");
}
int main(){
    int t=1;
    int T=1;
    while(t--){
        solve();
    }
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 10;
int A[maxn], cnt[maxn], st[maxn], ed[maxn];
LL D[maxn], C[maxn];

LL qpow(LL a, LL b) {
    LL ret = 1LL;
    while (b) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

LL inv(LL x) {
    return qpow(x, mod - 2);
}

LL c[2][maxn];
int lowbit(int s) {
    return s & (-s);
}
void modify(int o, int i, LL x) {
    while (i < maxn) c[o][i] = (c[o][i] + x) % mod, i += lowbit(i);
    return;
}
LL query(int o, int i) {
    LL ret = 0;
    while (i > 0) ret = (ret + c[o][i]) % mod, i -= lowbit(i);
    return ret;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) scanf("%d", A + i), cnt[A[i]]++;
    for (int i = N; i >= 1; --i) cnt[i] += cnt[i + 1];
    LL S = 1;
    for (int i = 1; i <= N; ++i) {
        cnt[i] -= N - i;
        if (cnt[i] <= 0) S = 0;
        else S = S * cnt[i] % mod;
    }
    if (S == 0) {
        puts("0");
        return 0;
    }
    for (int i = N; i >= 1; --i) {
        if (i == N || cnt[i + 1] == 1 || cnt[i] == 1) st[i] = ed[i] = i;
        else st[i] = st[i + 1], ed[st[i]] = i;
    }
    for(int i = 1; i <= N; ++i){
        LL pre;
        if(ed[st[i]] == i) pre = 1;
        else pre = D[i-1];
        D[i] = pre * (cnt[i] - 1) % mod * inv(cnt[i]) % mod;
    }
    LL ans = 0;
    for (int j = 1; j <= N; ++j) {
        ans = (ans + C[A[j]]) % mod;
        C[A[j]]++;
        if(!D[A[j]]) continue;
        LL tmp = (query(0, A[j] - 1) - query(0, ed[st[A[j]]] - 2) + mod) % mod;
        ans = (ans + tmp * D[A[j]]) % mod;
        modify(0, A[j], inv(D[A[j]]));
    }
    memset(c[0], 0, sizeof(c[0]));
    LL sum = 0;
    for (int j = N; j >= 1; --j) {
        sum = (sum + query(1, A[j] - 1)) % mod;
        modify(1, A[j], 1);
        if(!D[A[j]]) continue;
        LL tmp = (query(0, A[j] - 1) - query(0, ed[st[A[j]]] - 2) + mod) % mod;
        ans = (ans - tmp * D[A[j]] % mod + mod) % mod;
        modify(0, A[j], inv(D[A[j]]));
    }
    ans = (ans * inv(2) % mod + sum) * S % mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 9600
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s, t := io.Next(), io.Next()
	min := math.MaxInt64
	for i := 0; i+len(t) <= len(s); i++ {
		cnt := countDiff(s[i:i+len(t)], t)
		if cnt < min {
			min = cnt
		}
	}
	io.Println(min)
}

func countDiff(s, t string) int {
	cnt := 0
	for i := range s {
		if s[i] != t[i] {
			cnt++
		}
	}
	return cnt
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
 
int main(){
    int n;
    cin >> n;
    int mh = 0;
    int ans = 0;
    rp(i, 0, n){
        int h;
        cin >> h;
        if(h >= mh){
            ans ++;
            mh = h;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()

	f := make([]int, 60001)

	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				f[x*x+y*y+z*z+x*y+y*z+z*x]++
			}
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Println(f[i])
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 2332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char S;
  cin >> S;
 
  if (S == 'a'|| S == 'i'|| S == 'u'|| S == 'e'|| S == 'o')
    cout << "vowel" << endl;

    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  int n;
  cin>>n;
  int ans=n;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      int j=n/i;
      ans=min(ans,i+j-2);
    }
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
bool used[26];
int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (used[S[i] - 'a']) {
			cout << "no" << endl;
			return 0;
		}
		used[S[i] - 'a'] = 1;
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int l,s=0, max=0;
    for(int i=0;i<n;i++){
        cin >> l;
        if(l>max)
            max=l;
        s = s + l;
        
    }
    if (s>2*max)
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b) << endl;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> dp(3);
	for(int d=0;d<n;++d){
		vector<int> c(3);
		vector<int> new_dp(3,0);
		for(int i=0;i<3;++i) cin >> c[i];
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				if(i != j){
					new_dp[j] = max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp = new_dp;
	}

	cout << max({dp[0],dp[1],dp[2]});

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[100007];
vector<vector<ll>> V(10000);

int main(){
  ll N,K=0;
  cin >> N ;
  rep(i,10000){
    if((i*(i+1))/2==N){
      K=i;
    }
  }
  if(K==0){
    cout << "No" << endl;
    return 0;
  }
  else{
    cYes;
  }
  K++;
  cout << K << endl;
  ll X=1;
  rep(i,K-1){
    Rep(j,i+1,K){
      V[i].pb(X);
      V[j].pb(X);
      X++;
    }
  }
  rep(i,K){
    cout << V[i].size() << " ";
    rep(j,V[i].size()){
      cout << V[i][j];
      if(j!=V[i].size()-1){
        cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[60] = { 0 }, x[60] = { 0 };
	int i;
	cin >> s;
	for (i = 0; i < strlen(s) - 8; i++)
		x[i] = s[i];
	cout << x<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
*A,=map(int,input().split())
A.sort()
Q=int(input())
bc=[list(map(int,input().split()))for _ in range(Q)]

from collections import*
C=Counter(A)
ans=sum(A)

for b,c in bc:
    C[b],C[c],ans=0,C[c]+C[b],ans-b*C[b]+c*C[b]
    print(ans)

Measured memory_bytes: 40100
let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f

let rec print_trace = function
  | (a,b)::(c,d)::xs -> (
    Printf.printf "%d %d %d %d\n" (a+1) (b+1) (c+1) (d+1);
    print_trace ((c,d)::xs)
  )
  | _ -> ()

let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let a = Array.init h (fun _ -> Array.init w (fun _ -> Scanf.scanf " %d" ((+) 0))) in

  let moves, _ = for_fold 0 (h*w) ([], None) (fun (ac, tr) i ->
    let x = i / w in
    let y = if x mod 2 = 0 then i mod w else (w-1) - i mod w in
    match tr with
    | None ->
      if a.(x).(y) mod 2 = 1 then (ac, Some [(x, y)]) else (ac, None)
    | Some tr -> begin
      if a.(x).(y) mod 2 = 1 then (List.rev ((x,y)::tr) :: ac, None) else (ac, Some ((x,y)::tr))
    end)
  in

  let moves = List.rev moves in

  let n = List.fold_left (fun n x -> n + List.length x - 1) 0 moves in
  Printf.printf "%d\n" n;
  List.iter print_trace moves

Measured memory_bytes: 24832
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

// Main Code
int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    
    if (H % h == 0 && W % w == 0) {
        cout << "No\n";
        return 0;
    }
    
    vector<vector<ll>> a(H, vector<ll>(W, 0));
    ll sum = 0;
    rep(i, H) rep(j, W) {
        if (i % h == h - 1 && j % w == w - 1) a[i][j] = -h * w;
        else a[i][j] = 1;
        sum += a[i][j];
    }
    
    if (sum <= 0) {
        if (H % h == 0) {
            ll x = (-sum + (W % w) - 1) / (W % w) + 1;
            rep(i, W) a[H - 1][i] += x;
            rep(i, W / w) a[H / h * h - 1][(i + 1) * w - 1] -= w * x;
        } else {
            ll x = (-sum + (H % h) - 1) / (H % h) + 1;
            rep(i, H) a[i][W - 1] += x;
            rep(i, H / h) a[(i + 1) * h - 1][W / w * w - 1] -= h * x;
        }
    }
    
    cout << "Yes\n";
    rep(i, H) rep(j, W) cout << a[i][j] << " \n"[j == W - 1];
    return 0;
}


Measured memory_bytes: 5576
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
for i in range(1, N):
    dp[i] = min(dp[max(0,i-K):i]+abs(h[max(0,i-K):i]-h[i]))

print(dp[-1])

Measured memory_bytes: 22736
from collections import defaultdict
import sys
readline = sys.stdin.readline
write = sys.stdout.write

MOD = 10**9 + 9

def matmul(N, A, B):
    C = [[0]*N for i in range(N)]
    for i in range(N):
        for j in range(N):
            C[i][j] = sum(A[i][k] * B[k][j] for k in range(N)) % MOD
    return C

def prepare(N, H):
    mat = [[0]*N for i in range(N)]
    res = []
    for i in range(N):
        mat[i][i] = 1
    res.append([e[:] for e in mat])
    for i in range(N-1):
        mat[i][i+1] = mat[i+1][i] = 1
    res.append([e[:] for e in mat])
    while H:
        mat = matmul(N, mat, mat)
        res.append([e[:] for e in mat])
        H >>= 1
    return res
def matpow(X, N, h, MS):
    k = 1
    while h:
        if h & 1:
            mat = MS[k]
            X = [sum(ai*xi for ai, xi in zip(mat_i, X)) % MOD for mat_i in mat]
        h >>= 1
        k += 1
    return X

cnt = 1
def solve():
    W, H, N = map(int, readline().split())
    if W == H == N == 0:
        return False
    P = defaultdict(list)
    for i in range(N):
        x, y = map(int, readline().split())
        if y > 1:
            P[y-1].append(x-1)
    MS = prepare(W, H)
    *S, = P.items()
    S.sort()
    X = [0]*W
    X[0] = 1
    prv = 0
    for y, vs in S:
        X = matpow(X, W, y-prv, MS)
        for v in vs:
            X[v] = 0
        prv = y
    if prv < H-1:
        X = matpow(X, W, H-1-prv, MS)
    write("Case %d: %d\n" % (cnt, X[W-1]))
    return True
while solve():
    cnt += 1


Measured memory_bytes: 19156
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def time(s):
    h = s / 3600
    m = (s - (h * 3600)) / 60
    s = (s - (h * 3600)) - (m * 60)
    h, m, s = map(str, (h, m, s))
    print "%s:%s:%s" % (h, m, s)

s = int(raw_input())

if 0 <= s <= 86400:
    time(s)
else:
    sys.exit(0)

Measured memory_bytes: 4212