akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <queue>
using namespace std;

int main() {
    priority_queue<int> PQ;
    char com[10];
    while (~scanf("%s", com)) {
        if (com[0] == 'i') {
            int key; scanf("%d", &key);
            PQ.push(key);
        } else if (com[1] == 'x') {
            printf("%d\n", PQ.top());
            PQ.pop();
        } else if (com[0] == 'e') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 6540
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

typedef pair<LL, LL> PP;

string S;
int main() {
	cin >> S;
	reverse(S.begin(), S.end());
	int i = 0;
	bool flg = true;
	while (i < S.size()) {
		switch (S[i]) {
		case 'e':
			if (S.substr(i, 5) != "esare") flg = false;
			i += 5;
			break;
		case 'm':
			if (S.substr(i, 5) != "maerd") flg = false;
			i += 5;
			break;
		case 'r':
			if (S[i + 1] == 'e') {
				if (S.substr(i, 6) == "resare") i += 6;
				else if (S.substr(i, 7) == "remaerd") i += 7;
				else {
					flg = false; i = INF;
				}
			} else {
				flg = false; i = INF;
			}
			break;
		default:
			flg = false;
			i = INF;
		}
	}
	cout << (flg ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL t = 1;
    while (t--) {
        LL n;
        cin >> n;
        VL a(n);
        LL xo = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            xo = xo ^ a[i];
        }

        for (int i = 0; i < n; i++) {
            cout << (xo ^ a[i]) << " ";
        }

        cout << endl;

    }
    return 0;
    
}

Measured memory_bytes: 4744
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readInt64() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

const INF = int(1e4) + 1

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt64()
	}

	dp := make([]int, n)
	for i := 1; i < n; i++ {
		dp[i] = INF
	}

	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		v1 := dp[i-1] + abs(h[i]-h[i-1])
		v2 := dp[i-2] + abs(h[i]-h[i-2])
		if v1 <= v2 {
			dp[i] = dp[i-1] + abs(h[i]-h[i-1])
		} else {
			dp[i] = dp[i-2] + abs(h[i]-h[i-2])
		}
	}
	fmt.Println(dp[n-1])
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 2688
#include <cstdio>
#include <algorithm>

int main()
{
  long long k, a, b;
  scanf("%lld%lld%lld", &k, &a, &b);
  if (b - a <= 2)
  {
    printf("%lld\n", k + 1);
    return 0;
  }
  long long ans = 1 + std::min(a - 1, k);
  k -= std::min(a - 1, k);
  ans += (b - a) * (k / 2) + (k & 1);
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, D+1):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Measured memory_bytes: 8052
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int main()
{
    int N; cin >> N;
    
    int l = 0, r = N + 1;

    while (r - l > 1) {
        double mid = (l + r) / 2;

        if ((1 + mid) * (mid / 2) >= N) {
            r = mid;
        } else {
            l = mid;
        }
    }

    while (N) {
        if (N < r) {
            cout << N << endl;
            return 0;
        }
        cout << r << endl;
        N -= r;
        r--;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    if(S[A-1:C+1].count('##') > 0 or S[B-1:D+1].count('##')):
    # if(S[A:max(C,D)].count('##') > 1):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-2:D+1].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3540
// AC-Library

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <cassert>

#include <atcoder/convolution>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;
  vector<ll> b(m);
  for (auto &x: b) cin >> x;

  vector<ll> c = atcoder::convolution<998244353>(a, b);

  for (auto &x: c) cout << x << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 27204
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int		N;
	cin >> N;
	vector<int> a(N);
	int		ans = 0;
	for (int i = 0; i < N; i++)
		cin >> a.at(i);
	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
			ans += (a.at(i) * a.at(j));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    NavigableSet<Integer>[] nsa=new NavigableSet[26];
    for(int i=0;i<26;i++){
      nsa[i]=new TreeSet<Integer>();
    }
    for(int i=0;i<n;i++){
      nsa[s.charAt(i)-'a'].add(i);
    }
    int q=sc.nextInt();
    for(int i=0;i<q;i++){
      if(sc.nextInt()==1){
        int idx=sc.nextInt();
        int ch=sc.next().charAt(0)-'a';
        for(int j=0;j<26;j++){
          if(ch==j){
            nsa[j].add(idx-1);
          }else{
            nsa[j].remove(idx-1);
          }
        }
      }else{
        int l=sc.nextInt()-1;
        int r=sc.nextInt()-1;
        int ans=0;
        for(int j=0;j<26;j++){
          Integer e=nsa[j].ceiling(l);
          if(e!=null&&e<=r){
            ans++;
          }
        }
        System.out.println(ans);
      }
    }
  }
}

Measured memory_bytes: 105100
class Main{
    public static void main(String[] a){
    	
    	
    	for(int i=1; i<10; i++){
    		for(int j=1; j<10; j++){
    			System.out.println(i + "x" + j + "=" + i*j );
    		}
    	}
    	
    	
    }
}

Measured memory_bytes: 17020
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static int H;
        static int W;
        static string[] S;
        static int[,] used;
        static Queue<Tuple<int, int>> que;
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = long.Parse(Console.ReadLine());
            var NMD = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
            var N  = NMD[0];
            var M  = NMD[1];
            var D  = NMD[2];
           
            if(D == 0)
            {
                Console.WriteLine((M-1)/(N));
            }
            else
            {
                var tmp = N - D;
                Console.WriteLine((M - 1)*(tmp*2) / (N*N));
            }
            

           
        }
    }
}


Measured memory_bytes: 28308
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <list>

using namespace std;



int main(void){
    long long X,tmp;
    long long  ans=0;
    

    cin>>X;
    tmp=100;

    for(long long i=1;tmp < X;i++){
        ans=i;
        tmp=tmp*1.01;
        
    }



    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,a[1000],num;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for (int i=0;i<n-1;i++) num+=a[i];
  	if (num<=a[n-1])
      	cout<<"No"<<endl;
 	else
      	cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int dividers_cnt(int a) {
  set<int> res;
  FOR(i,1,(int)(sqrt(a))+1) {
    if (a%i == 0) {
      res.insert(i);
      res.insert(a/i);
    }
  }
  return res.size();
}

int main() {
  int N;cin>>N;
  int ans = 0;
  FOR(i,1,N+1){
    if (i%2 == 1 && dividers_cnt(i) == 8) ans++;
  }
  OUT(ans);
  
  return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n==0)break;
   var a = arr.shift().split(" ").map(Number);
   var sum = a.reduce((a,b)=>a+b);
   console.log(a.filter(v => v<=sum/n).length);
}


Measured memory_bytes: 21140
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int m;
   	cin>>m;
   	cout<<48-m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 287644PV
int mod = 1000000000+7;

void dfs(int start, const vector<vector<int>> &graph, vector<int> &memo,vector<bool> &visited)
{
    visited[start] = true;
    for (int i = 0; i < graph[start].size(); ++i) {
        if(!visited[graph[start][i]]) {
            dfs(graph[start][i], graph, memo, visited);
        }
        memo[start] = max(memo[start], memo[graph[start][i]]+1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    vector<string> input(h);
    for (int i = 0; i < h; ++i) {
        cin >> input[i];
    }

    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0] = 1;
    for (int i = 1; i < w; ++i) {
        dp[0][i] = input[0][i-1] == '.' && dp[0][i-1] == 1;
    }
    for (int i = 1; i < h; ++i) {
        dp[i][0] = input[i-1][0] == '.' && dp[i-1][0] == 1;
    }
    for (int i = 1; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if(input[i-1][j] == '.')
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
            if(input[i][j-1] == '.')
                dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
        }

    }
    cout << dp[h-1][w-1] % mod;


}

Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int x, n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> n;

  vector<bool> p(206, false);

  REP(i, n) {
    int a;
    cin >> a;
    p[a + 100] = true;
  }

  int ans = INF, t;
  REP(i, 205) {
    if(!p[i]) {
      if(abs(x - (i - 100)) < ans) {
        ans = abs(x - (i - 100));
        t = (i - 100);
      }
    }
  }

  cout << t << endl;
}


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

namespace ConsoleApplication1
{
    struct Doll : IComparable
    {
        internal int h, r, size;

        public int CompareTo(object obj)
        {
            Doll other = (Doll)obj;
            return size - other.size;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                List<Doll> list = new List<Doll>();

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');

                    Doll temp;
                    temp.h = int.Parse(input[0]);
                    temp.r = int.Parse(input[1]);
                    temp.size = temp.h * temp.r * temp.r;
                    list.Add(temp);
                }

                int m = int.Parse(Console.ReadLine());

                for (int i = 0; i < m; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');

                    Doll temp;
                    temp.h = int.Parse(input[0]);
                    temp.r = int.Parse(input[1]);
                    temp.size = temp.h * temp.r * temp.r;
                    list.Add(temp);
                }

                list.Sort();

                int[] memo = Enumerable.Repeat(1, list.Count).ToArray();

                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < i; j++)
                    {
                        if (list[i].h > list[j].h && list[i].r > list[j].r)
                        {
                            memo[i] = Math.Max(memo[i], memo[j] + 1);
                        }
                    }
                }
                sb.AppendLine(memo.Max().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i,n)cin >> a[i];
   ll odd = 0;
   rep(i,n)odd+=a[i]%2;
   ll even = n-odd;
   ll ff = (1LL<<even);
   ll ans = 1;
   rep(i,n)
   {
      ans*=3;
   }
   ans -= ff;
   cout<<ans<<endl;
   
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<string> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sort(a.at(i).begin(),a.at(i).end());
  }
  sort(a.begin(),a.end());
  vector<long> count(1);
  long k=0,ans=0;
  for(int i=0;i<N-1;i++){
    if(a.at(i)==a.at(i+1))count.at(k)++;
    else{
      k++;
      count.push_back(0);
    }
  }
  int A=count.size();
  for(int i=0;i<A;i++)ans+=count.at(i)*(count.at(i)+1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    long long W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<(W*H)/2.0<<endl;
    int a=(W==2*x&&H==2*y)?1:0;
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = 3010;
// コインをi個投げた時に、j個が表になる確率
vector<vector<long double>> DP(MAXN, vector<long double>(MAXN, 0));

int main()
{
  int64_t N;
  cin >> N;
  vector<long double> P(N);
  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
  }
  DP.at(0).at(0) = 1.0; // 0個投げた時は、表の枚数は必ず0
  for (int i = 1; i <= N; i++)
  {
    for (int j = 0; j <= N; j++)
    {
      long double p, a = 0, b = 0;
      if (j != 0)
        a = DP.at(i - 1).at(j - 1) * P.at(i - 1); // i-1個, j-1個 * 表
      b = DP.at(i - 1).at(j) * (1 - P.at(i - 1)); // i-1個, j個 * 裏
      DP.at(i).at(j) = a + b;
    }
  }
  long double ans = 0;
  for (int j = 0; j <= N; j++)
  {
    if (j > N / 2)
    {
      ans += DP.at(N).at(j);
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 141952
from itertools import accumulate

# 入力
H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

# 転置 + 行ごと(つまり列ごと)の白チョコの数を数えている
accs = [[0]+list(accumulate(l)) for l in zip(*S)]

ans = float('inf')

for i in range(1 << H - 1):
    parts = []
    cuts = 0
    for k in range(H - 1):
        if i & (1 << k):
            cuts += 1
            parts.append(k+1)
    
    parts.append(H)
    cts = [0]*len(parts)
    for j in range(W):
        prev = 0
        flag1 = False
        for idx, p in enumerate(parts):
            c = accs[j][p] - accs[j][prev]
            cts[idx] += c
            if cts[idx] > K:
                flag1 = True
                break
            prev = p
        if flag1:
            cuts += 1
            prev = 0
            flag2 = False
            for idx, p in enumerate(parts):
                c = accs[j][p] - accs[j][prev]
                if c > K:
                    flag2 = True
                    break
                cts[idx] = c
                prev = p
            if flag2:
                break
    else:
        ans = ans if ans < cuts else cuts

print(ans)

Measured memory_bytes: 3316
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/04/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  vector<pair<int, int>> query(m);
  for (int i = 0; i < m; i++)
    cin>>query[i].first>>query[i].second;
  auto solve = [&]() {
    int f = n>1?pow(10l, n-1):0;
    int t = pow(10l, n)-1;
    for (int i = f; i <= t; i++) {
      bool ok = true;
      for (auto q : query) {
        auto s = q.first;
        auto c = q.second;
        auto num = i;
        while (s<n)
          num/=10, s++;
        if (num%10 != c) {
          ok = false;
          break;
        }
      }
      if (ok)
        return i;
    }
    return -1;
  };
  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};

fn main() {
    input! {
        n: usize,
        mut k: usize,
        mut a: [Usize1; n],
    }
    let mut ans = 0;
    while k > 0{
        if k & 1 == 1{
            ans = a[ans];
        }
        k >>= 1;
        let mut na = vec![0; n];
        for i in 0..n{
            na[i] = a[a[i]];
        }
        a = na;
    }
    ans += 1;
    println!("{}", ans);
}


Measured memory_bytes: 6572
import * as fs from 'fs';


function main(input) {
  input = input.split('\n');
  const S = parseInt(input[0]);
  const X = 10 ** 9 + 7;
  const fsList = [1, 0, 0, 1];
  for (let i = 4; i <= S; i++) {
    fsList.push((fsList[i - 1] + fsList[i - 3]) % X);
  }
  console.log('%d', fsList[S]);
}

main(fs.readFileSync('/dev/stdin', 'utf8'));


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

int main(){
    long long N,K;
    cin >> N >> K;

    N %= K;//ほぼこれに等しい
    long long def;
    while(true){
        def = abs(N - K);
        if(N > def){
            N = def;
        }else{
            break;
        }
    }
    cout << N << endl;
    
    return 0;
}

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

#define MOD (1000000000+7)

long long powm( long long x, int n )
{
	long long res = 1;
	while( n ) {
		if( n % 2 ) {
			res *= x;
			res %= MOD;
		}
		x *= x;
		x %= MOD;
		n /= 2;
	}
	return res;
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	long long ans1 = 0;
	for( int i = N - 1; i > 0; i-- ) {
		for( int j = 0; j < i; j++ ) {
			if( A[i] < A[j] ) {
				ans1++;
				ans1 %= MOD;
			}
		}
	}
	long long ans2 = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( i == j ) continue;
			if( A[j] < A[i] ) {
				ans2++;
				ans2 %= MOD;
			}
		}
	}
	long long ans = ans2 * K % MOD;
	ans = ans * (K - 1) % MOD;
	ans = ans * powm( 2, MOD - 2 ) % MOD;
	ans = (ans + ans1 * K % MOD) % MOD;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,i,j,p,q,tot=0;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>arr[i];
			tot=tot^arr[i];
		}
		for(i=0;i<N;i++){
			p=tot^arr[i];
			cout<<p<<" ";
		}
	}	
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0; i<N; i++){
      cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  int answer=0;
for(int i=0; i<K; i++){
answer+=p.at(i);
}
cout<<answer<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for (int i =1; i <= (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll n,sum=0;cin>>n;
  rep(i,n){
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum;
  

}

Measured memory_bytes: 3624
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
string s;

int main() {
	ll a[3], k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a + 3);
	ll b = a[2];
	rep(i, k) {
		b *= 2;
	}
	cout << a[0] + a[1] + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
inline long long	read()//不管是正负数，都可以 
{
	long long x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(long long a){
	write(a); puts("");
}
#include<map>
#include<cmath>
const long long N=100005,oo=1e18;
long long a[N],b[N],c[N],tot,n,mmax,mmin,pos;
int main(){
	n=read();
    for(long long i=1;i<=n;i++){
    	c[i]=b[i]=a[i]=read();
	}
	a[0]=b[0]=-oo; tot=0;
	for(long long i=1;i<=n&&tot<=2*n;){
		mmax=-oo; if(b[i]>=b[i-1]){i++; continue;}
		for(long long j=1;j<=n;j++){
			if(b[j]>mmax){
				mmax=b[j]; pos=j;
			}
		}
		b[i]+=mmax; if(b[i]>=b[i-1])i++; tot++;
	}
	if(tot<=2*n){
		cout<<tot<<endl;
		for(long long i=1;i<=n;){if(a[i]>=a[i-1]){i++; continue;} mmax=-oo;
		for(long long j=1;j<=n;j++){
			if(a[j]>mmax){
				mmax=a[j]; pos=j;
			}
		}
		cout<<pos<<" "<<i<<endl;
		a[i]+=mmax; if(a[i]>=a[i-1])i++;}
		return 0;
	}
	tot=0;
	a[n+1]=c[n+1]=oo;
	for(long long i=n;i;){
		mmin=oo; if(c[i]<=c[i+1]){i--; continue;}
		for(long long j=1;j<=n;j++){
			if(c[j]<mmin){
				mmin=c[j]; pos=j;
			}
		}
		c[i]+=mmin; if(c[i]<=c[i+1])i--;tot++;
	}
	cout<<tot<<endl;
	for(long long i=n;i;tot++){
		mmin=oo; if(a[i]<=a[i+1]){i--; continue;}
		for(long long j=1;j<=n;j++){
			if(a[j]<mmin){
				mmin=a[j]; pos=j;
			}
		}
		cout<<pos<<" "<<i<<endl;
		a[i]+=mmin; if(a[i]<=a[i+1])i--;
	}
}

Measured memory_bytes: 888
#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>
#include <complex>
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, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; 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 A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V;

int main(){
  cin >> K >> X;
  cout << (K*500>=X ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heappush, heappop
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

graph = [[] for _ in range(n)]
edge = {}
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    edge[(a, b)] = i
    edge[(b, a)] = i

def bfs(graph, start, n):
    visited = [-1] * n
    que = deque()
    color = [0] * (n - 1)
    visited[start] = 0
    que.append(start)
    while que:
        node = que.popleft()
        c = 1
        for e in graph[node]:
            if visited[e] < 0:
                if visited[node] == c:
                    c += 1
                visited[e] = c
                color[edge[(e, node)]] = c
                que.append(e)
                c += 1
    return color

r = bfs(graph, 0, n)
ans = max(r)
print(ans)
for k in r:
    print(k)


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ll> a(n);
	for(ll &i:a) cin>>i;
	sort(a.begin(),a.end());
	ll ans=a[n-1];
	int t=n-2,i=t;
	while(t){
		int k=min(2,t);
		t-=k;
		ans+=k*a[i--];
	}
	cout<<ans;
}

Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
Graph G;
vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second &1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main()
{
    ll n; cin >> n;
    G.assign(n, vector<Edge>());
    for (int i = 0; i < n-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(n, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;

    return 0;
}


Measured memory_bytes: 11684
import java.util.Scanner;
import java.util.ArrayList;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    ArrayList <Integer> li = new ArrayList <Integer>();
    ArrayList <Integer> lili = new ArrayList <Integer>();
    for(int i=0; i<number-1; i++){
      int a = sc.nextInt();
      li.add(a);
    }
    for(int i=0;i<number-1;i++){
      lili.add(0);
    }
    for(int i=0; i<number-1; i++){
      int a = li.get(i);
      lili.set(a-1,lili.get(a-1)+1);
    }
    for(int i=0;i<number-1;i++){
      System.out.println(lili.get(i));
    }
    System.out.println(0);
  }
}


Measured memory_bytes: 67952
#include<cstdio>
const int maxn=100005;
int sum[maxn];
int main(){
  sum[0]=0;
  for(int i=1;i<maxn;++i)sum[i]=sum[i/10]+i%10;
  int n;scanf("%d",&n);
  int ans=0x3f3f3f3f;
  for(int i=1;i<n;++i)if(sum[i]+sum[n-i]<ans)ans=sum[i]+sum[n-i];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_]={1},X;i,j,k,t;c(a,b)int*a,*b;{t=a[1]-b[1]?:*a-*b;}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<_;)I[X]=p(s=F[X]=X*s%M,M-2);for(;~scanf("%d",A+i);)i++-1||gets(P);for(qsort(A,i/2,8,c);j<i;P[j]=X,j+=2)for(X=f(s=A[k=j]-=1,t=A[j+1]-=1);k;X=s<A[k-=2]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M);printf("%d",X);}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

bool primes[107];
vector<int> store;

void sieve(int n)
{
    for (int i = 2; i <= n; i++) {
        if (primes[i]) continue;
        for (int j = i*i; j <= n; j += i) {
            primes[j] = 1;
        }
        store.push_back(i);
    }
}

int ans[1007];

void cal(int n)
{
    for (auto x : store) {
        if (x > sqrt(n)) break;
        if (n % x == 0) {
            int cnt = 0;
            while (n % x == 0) n /= x, cnt++;
            ans[x] += cnt;
        }
    }
    if (n > 1) ans[n]++;
}

int main()
{
    sieve(1e2);
    int n;
    cin >> n;

    for (int i = 2; i <= n; i++) cal(i);

    ll out = 1;
    for (int i = 2; i <= n; i++) {
        if (ans[i]) {
            out = (out * (ans[i]+1)) % mod;
        }
    }

    cout << out << "\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int sum=0,a,b,c,d;
	fscanf(stdin, "%d %d %d %d", &a, &b, &c, &d);
	sum = a + b + c + d;
	fscanf(stdin, "%d %d %d %d", &a, &b, &c, &d);
	if (sum >= a + b + c + d) fprintf(stdout,"%d\n", sum);
	else fprintf(stdout, "%d\n", a + b + c + d);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

ll ans = (ll)(1e11);
void calc(ll w, ll h) {
    rrep(a, 1, w) {
        ll w1 = a * h;
        ll w2 = (w - a) * (h / 2);
        ll w3 = w * h - w1 - w2;
        ans = min(ans, max({w1, w2, w3}) - min({w1, w2, w3}));
        w2 = (w - a) / 2 * h;
        w3 = w * h - w1 - w2;
        ans = min(ans, max({w1, w2, w3}) - min({w1, w2, w3}));
    }
}
int main() {
    ll h, w; cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    calc(w, h); calc(h, w);
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

C = input().split()

B = C[:]
S = C[:]

# bubble sort
flag = 1
while(flag):
    flag = 0
    for x in range(1, N):
        if B[x][1:] < B[x-1][1:]:
            B[x], B[x-1] = B[x-1], B[x]
            flag = 1

# sectionSot
for x in range(0,N):
    minj = x
    for j in range(x,N):
        if S[j][1:] < S[minj][1:]:
            minj = j
    if minj != x:
        S[x], S[minj] = S[minj], S[x]

for i in range(1, N):
    v = C[i]
    j = i - 1
    while(j >=0 and C[j][1:] > v[1:]):
        C[j+1] = C[j]
        j -= 1
    C[j+1] = v

if(C == B):
    print(" ".join(b for b in B))
    print("Stable")
else:
    print(" ".join(b for b in B))
    print("Not stable")


if(C == S):
    print(" ".join(b for b in S))
    print("Stable")
else:
    print(" ".join(b for b in S))
    print("Not stable")

Measured memory_bytes: 7824
/*In the name of Allah*/
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAX 100011
int ans[MAX];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int last_r  = 0;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'R')last_r = i;
		else{
			if((i - last_r )&1)ans[last_r + 1]++; 
			else ans[last_r]++;
		}
	}
	int last_l = 0;
	for(int i = s.size() - 1; i >= 0 ; i--){
		if(s[i] == 'L')last_l = i;
		else{
			if((last_l - i)&1)ans[last_l-1]++;
			else ans[last_l]++;
		}
	}
	for(int i = 0; i < s.size();  i++)cout<<ans[i]<<" ";
	return 0;
}


Measured memory_bytes: 1104
#include<stdio.h>
#include<string.h>
int main(){
  char str[1100];
  int l,i,j,k,flg;
  fgets(str,1050,stdin);
  l=strlen(str);
  str[l-1]=' ';
  flg=0;
  for(i=0;;i++){
  loop:
    if(i>=l-1)break;
    for(j=i;j<l;j++){
      if(str[j]==' '||str[j]=='.'||str[j]==','){
	if(j-i>=2&&j-i<=5){
	  if(flg==1)printf(" ");
	  flg=1;
	  for(k=i-1;k<j;k++){
	    printf("%c",str[k]);
	  }
	}
	for(;str[j]==' '||str[j]=='.'||str[j]=='.';j++);
	i=j+1;
	goto loop;
      }
    }
  }
  printf("\n");
  return 0;
}

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

using namespace std;
#define MOD 998244353

long long dp[3005][3005];

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


	int n, s, x;
	int cnt = 0;
	cin >> n >> s;
	int arr[n+1];
	// long long dp[s+1][n+1];
	// memset(dp, 0, sizeof(long long) * (n+1)*(s+1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		arr[i] = x;
	}

	for (int k = 1; k <= n; k++) {
		for (int x = 0; x <= s; x++) {
			dp[x][k] = dp[x][k-1] * 2 % MOD;
			if (x - arr[k] >= 0) dp[x][k] = (dp[x][k] + dp[x-arr[k]][k-1]) % MOD;

		}
	}
	
	cout << dp[s][n] << "\n";
}


Measured memory_bytes: 74080
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, D int
	fmt.Scan(&N, &D)
	X := make([][]float64, N)
	for i := 0; i < N; i++ {
		X[i] = make([]float64, D)
		for j := 0; j < D; j++ {
			fmt.Scan(&X[i][j])
		}
	}

	ans := 0
	for i := 0; i < N-1; i++ {
		x1 := X[i]
		for j := i + 1; j < N; j++ {
			var s float64
			x2 := X[j]
			for d := 0; d < D; d++ {
				s += math.Pow(math.Abs(x1[d]-x2[d]), 2)
			}
			a := math.Sqrt(s)
			if float64(int(a)*int(a)) == s {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int x,a,b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  char s[100010];
  int c[26];
  scanf("%s",s);
  int l=strlen(s);
  for(int i=0;i<26;i++){
    c[i]=0;
  }
  for(int i=0;i<l;i++){
    c[s[i]-'a']++;
  }
  for(int i=0;i<26;i++){
    if(c[i]==0){
      printf("%c\n",i+'a');
      return 0;
    }
  }
  
  printf("None\n");
      return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
	double r;
	cin >> r;
	
	cout << fixed << setprecision(6)<< M_PI * r * r << " " << 2 * M_PI * r << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1288
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x): #親を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y): #和集合の生成
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x): #所属する集合の大きさ
        return -self.parents[self.find(x)]

    def same(self, x, y): #同じ集合に属しているか判定
        return self.find(x) == self.find(y)

    def members(self, x): #同じ集合に属する要素全列挙
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self): #集合のリーダー全列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self): #集合の数
        return len(self.roots())

    def all_group_members(self): #辞書型,{(リーダーの番号):(その集合の要素全列挙)}
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,q=map(int,input().split())
uf=UnionFind(n)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        uf.union(b,c)
    else:
        if uf.same(b,c):
            print(1)
        else:
            print(0)

Measured memory_bytes: 11652
#include<vector>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;

int compare(const pair<double,string> l,const pair<double,string> r) {
  return l.first > r.first;
}

int main() {

  int n;
  double p,a,b,c,d,e,f,s;
  int m;

  while(1) {
    cin>>n;
    if(!n) break;
    vector< pair<double,string> > v;
    vector< pair<string,double> > vs;
    while(n--) {
      string st;
      cin>>st;
      cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      double income = f *s*m - p;
      double time = a + b + c;
      for(int i=0; i<m; i++)
	time += d + e;

      pair<string,double> p = pair<string,double>( st, income/time );
      vs.push_back(p);
    }

    sort(vs.begin(),vs.end());
    for(int i=0; i<vs.size(); i++) {
      v.push_back( pair<double,string>(vs[i].second, vs[i].first) );
    }

    stable_sort( v.begin(), v.end(), ::compare );
    for(int i=0; i<v.size(); i++)
      cout<<v[i].second<<endl;
    cout<<"#"<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
int main(){
	string s;
	cin >> s;
	int ans = 0;
	FOR(i,0,3)if(s[i]=='1')ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    cin >> n;
    int m = n % 10;
    if (m == 3) {
        cout << "bon" << endl;
    } else 
    if (m == 0 || m == 1 || m == 6 || m == 8){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3620
N,K = map(int,input().split())
snuke = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))

    for j in A:
        snuke[j-1] += 1
cnt = 0
for i in snuke:
    if i == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  for(int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }

  long long ans = 0;
  for(auto& p : mp) {
    int s = p.second;
    ans += (long long)s * (s-1) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136