akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var fiveHund = int.Parse(Console.ReadLine());
        var hund = int.Parse(Console.ReadLine());
        var fifty = int.Parse(Console.ReadLine());
        var result = int.Parse(Console.ReadLine());
        var count = 0;

        for (int i = 0; i < fiveHund + 1; i++)
        {
            var fh = 500 * i;

            for (int j = 0; j < hund + 1; j++)
            {
                var h = 100 * j;

                for (int k = 0; k < fifty + 1; k++)
                {
                    var f = 50 * k;

                    if (fh + h + f == result)
                    {
                        count++;
                    }
                }
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
vector<int> div(int n){
  vector<int> D; int k;
  for(k=1; k*k<=n; k++){ if(n%k==0){ D.push_back(k); } }
  k=D.size(); k--; if(D[k]*D[k]==n){ k--; }
  while(k>=0){ D.push_back(n/D[k--]); }
  return D;
}

int main(){
int N, ans=0; cin >> N; vector<int> A(N+1); map<int, bool> ksht;
REP(i, N){ cin >> A[i]; }
A[N]=1e9;
sort(A.begin(), A.end());
REP(i, N){ 
  vector<int> V=div(A[i]); bool flag=false;
  REP(j, V.size()){ if(ksht[V[j]]){ flag=true; break; } }
  if(!flag && A[i]!=A[i+1]){ ans++; }
  ksht[A[i]]=true; 
}
cout << ans << "\n";
}

Measured memory_bytes: 33096
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[10];
  cin>>a[0]>>a[1];
  sort(a,a+2);
  if(a[0]!=1)
    cout<<1<<endl;
  else if(a[1]!=2)
    cout<<2<<endl;
  else
    cout<<3<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt(); //aピザの値段
		int b = stdIn.nextInt(); //bピザの値段
		int ab = stdIn.nextInt(); //abピザの値段
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		int a_b = (ab*2); //aピザ1枚bピザ1枚 
		
		long sum = 0;
		
		//int min = Math.min(a_b, a+b); //abを買うかa,bそれぞれで買うか
		
		int t = 0;
		if(a_b > a+b) {
			t = 1;
		}else {
			t = 2;
		}
		
		
		if(t==2) {
				sum += Math.min(x, y)*a_b;
				if(x > y) {
					sum += (x-y)*a;
				}else {
					sum += (y-x)*b;
				}
			sum = Math.min(sum, a_b*(Math.max(x, y)));
	
		}else {
			sum += (x*a)+(y*b);
		}
		
		System.out.println(sum);
		
		
		
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>

#define int long long
#define ld long double
#define db double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debx cout << " X " << endl;
#define deby cout << " Y " << endl;
#define debz cout << " Z " << endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

using namespace __gnu_pbds; 
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; 
/*  
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero) 
    order_of_key()  - The number of items in a set that are strictly smaller than our item 
    Rest same as set
*/
 
int mpow(int a, int b){
    a %= MOD;
    if(!b)
        return 1;
    int temp = mpow(a, b/2);
    temp = (temp*temp) % MOD;
    if(b%2)
        return (a * temp) % MOD;
    return temp;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b/2);
    temp = (temp * temp);
    if(b%2)
        return (a * temp);
    return temp;
}
int mod_in(int n){
    return mpow(n, MOD-2);
}
int cl(int a, int b){
    if(a%b)
        return 1 + a/b;
    return a/b;
}

int32_t main(){
    fastio;
    int a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(v <= w){
        if(a==b)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    else{
        int T  = cl(abs(a-b) , (v - w));
        if( T <= t)
            cout << "YES" << endl;
        else
            cout << "NO";
    }
}

Measured memory_bytes: 3652
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,k; cin>>n>>k;
    ld ans=0.0,res=0;
    vi a(n+1);
    for (int i=1;i<=n;i++) {
        cin>>a[i]; a[i]++; 
        if (i<=k) ans += a[i]/2.0;
    }
    res=ans;
    for (int i=k+1;i<=n;i++){
        ans -= a[i-k]/2.0;
        ans += a[i]/2.0;
        res = max(res,ans);
    }
    cout.precision(20);
    cout << res << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4800
import sys
sys.setrecursionlimit(10**9)

N = int(input())
MOD = 10**9+7
G = [[] for _ in range(N)]
for i in range(N-1):
    x, y = map(lambda x: int(x)-1, input().split())
    G[x].append(y)
    G[y].append(x)

def dfs(v, r):
    w, b = 1, 1
    for u in G[v]:
        if u == r: continue
        c_w, c_b = dfs(u, v)
        w *= c_w + c_b
        b *= c_w
    w %= MOD
    b %= MOD
    return w, b

print(sum(dfs(0, None))%MOD)

Measured memory_bytes: 939048
H,W,K = map(int,input().split())
C = list(list(input())for _ in range(H))
ans = 0
for h in range(2**H):
    for w in range(2**W):
        count = 0
        for i in range(H):
            if 1<<i & h:
                continue
            for j in range(W):
                if 1<<j & w:
                    continue
                if C[i][j] == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)

Measured memory_bytes: 74368
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;
ll N,Q,x[200200],d[200020],xd[200020];
//xd[i]はiを根とする木のiの子供x[j]を全て足したもの。
bool used[200020];
vector<ll> edge[200200];




//weightはxd[s]に入れるべき値
void dfs(ll s,ll weight){
  used[s]=true;
  xd[s]=weight;
  for(const auto t:edge[s]){
    if(!used[t]){
      dfs(t,weight+x[t]);
    }
  }
}

int main(){
  cin>>N>>Q;
  fill(x,x+N+2,0);
  fill(xd,xd+N+2,0);
  REP(i,N-1){
    ll a,b;
    cin>>a>>b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  REP(i,Q){
    ll p,q;
    cin>>p>>q;
    x[p]+=q;
  }

  dfs(1,x[1]);

  FOR(i,1,N+1){
    cout<<xd[i]<<endl;
  }
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


bool isPrime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll  i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

int main()
{
    ll x,n;
    cin>>x>>n;
    ll arr[n],i;
    unordered_map<ll,ll>mp;

    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }

    ll mn = INF;
    ll ans;
    for(i=0;i<=200;i++)
    {
        if(mp.find(i)==mp.end())
        {
            if(abs(i-x)<mn)
            {
                mn = abs(i-x);
                ans = i;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=55;
const ll INF=~0u>>2;
ll dp[N][N][N*N],n,a[N],A,ans;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();A=read();
	for(int i=1;i<=n;++i) a[i]=read();
	dp[0][0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=n;++j){
			for(int k=0;k<=A*n;++k){
				dp[i][j][k]+=dp[i-1][j][k];
				if(k-a[i]>=0&&j>=1) dp[i][j][k]+=dp[i-1][j-1][k-a[i]];
			}
		}
	}
	for(int i=1;i<=n;++i)ans+=dp[n][i][i*A];
	printf("%lld",ans);
	return 0; 
}

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

namespace ConsoleApp1
{
    static class CGreenBin
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var sList = new List<string>();

            long count = 0;
            var counter = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                var chList = Console.ReadLine().ToList();
                chList.Sort();
                string s = new string(chList.ToArray());
                if (counter.ContainsKey(s))
                {
                    count += counter[s];
                    counter[s]++;
                    continue;
                }
                counter.Add(s, 1);
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 32316
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=2e5;
int head[N+5];
struct mode
{
	int v,nxt;
}edge[2*N+5];
int d[N+5];
int vis[N+5];
priority_queue<pair<int,int> > q;
int cnt=1;

void add(int u,int v)
{
	edge[cnt].v=v;
	edge[cnt].nxt=head[u];
	head[u]=cnt++;
}

void dijkstra()
{
	memset(d,0x3f,sizeof(d));
	memset(vis,0,sizeof(vis));
	d[1]=0;
	q.push(make_pair(0,1));
	while(!q.empty())
	{
		int x=q.top().second;
		q.pop();
		if(vis[x])
			continue;
		vis[x]=1;
		for(int i=head[x];i;i=edge[i].nxt)
		{
			int y=edge[i].v;
			if(d[y]>d[x]+1)
			{
				d[y]=d[x]+1;
				q.push(make_pair(-d[y],y));
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i)
	{
		int u,v;
		cin>>u>>v;
		add(u,v);
	}
	dijkstra();
	//cout<<d[n]<<endl;
	if(d[n]<=2)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 6264
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[51][51][2501]={};
int main(){
	int N;
	int A;
	int x[50];
	ll ans=0;
	scan(N);scan(A);
	rep(i,N){
		scan(x[i]);
	}
	dp[0][0][0]=1;
	rep(i,N){
		rep(kosu,i+1){
			rep(xsum,i*50+1){
				dp[i+1][kosu][xsum]+=dp[i][kosu][xsum];
				//if(dp[i+1][kosu][xsum]>=1) printf("i:%d kosu:%d xsum:%d dp:%lld\n",i+1,kosu,xsum,dp[i+1][kosu][xsum]);
				dp[i+1][kosu+1][xsum+x[i]]+=dp[i][kosu][xsum];
				//if(dp[i+1][kosu+1][xsum+x[i]]>=1) printf("i:%d kosu:%d xsum:%d dp:%lld\n",i+1,kosu+1,xsum+x[i],dp[i+1][kosu+1][xsum+x[i]]);
			}
		}
	}
	rep1(kosu,N){
		ans+=dp[N][kosu][A*kosu];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 49024
MOD=10**9+7

N=int(input())
A=list(map(int, input().split()))
X=[0]*N
X[0]=A[0]+0
X[0]%=MOD
for i in range(1, N):
  X[i]=X[i-1]+A[i]
  X[i]%=MOD
  
ans=0
for i in range(1, N):
  tmp=X[i-1]*A[i]%MOD
  ans=(ans+tmp)%MOD
print(ans)

Measured memory_bytes: 31424
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    ll ans = 0;
    Rep(i, 1, n+1) ans += i * (1 + (n/i))*(n/i)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	G := make([][]int, N)
	for i := 0; i < M; i++ {
		x, y, _ := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		G[x] = append(G[x], y)
		G[y] = append(G[y], x)
	}
	var dfs func(cur int)
	done := make([]bool, N)
	dfs = func(cur int) {
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if done[next] {
				continue
			}
			done[next] = true
			dfs(next)
		}
	}
	ans := 0
	for i := 0; i < N; i++ {
		if !done[i] {
			ans++
			dfs(i)
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 35328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;


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

  ll N,K; cin>>N>>K;
  ll ans = K * pow(K - 1, N - 1);
  cout << ans << endl;
}


Measured memory_bytes: 384
local read = io.read
local remove = table.remove

local N = read("*n")
local a = {}
for i = 1, 3*N do
	a[i] = read("*n")
end

table.sort(a)

local sum = 0LL
for i = 1, N do
	remove(a)
	sum = sum + remove(a)
end

print(tostring(sum):sub(1, -3))


Measured memory_bytes: 6596
n = gets.to_i
a = gets.split.map(&:to_i)

def selection_sort(a, n)
  cnt = 0
  0.upto(n-1) do |i|
    minj = i

    i.upto(n-1) do |j|
      if a[j] < a[minj]
        minj = j
      end
    end

    if i != minj
      a[i], a[minj] = a[minj], a[i]
      cnt += 1
    end

  end
  puts a.join(" "), cnt
end

selection_sort(a, n)


Measured memory_bytes: 8852
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n, y;
	cin >> n >> y;
	for (int a = 0; a <= n; a++) {
		for (int b = 0; b <= n; b++) {
			int c = n - a - b;
			if (c < 0 || n < c) continue;
			if (a * 10000 + b * 5000 + c * 1000 == y) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


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;

  return;
}

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;}


long int modpow(long int a,long int n,long int mod){
  long 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;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  char s[2000];
  scanf("%s",s);

  char t[2000];
  scanf("%s",t);

  //strlen()で文字列の長さを取得できる
  //それを忘れてもforでif(s[i]=='\0')みたいなことをすれば取得できる
  int n=strlen(s);
  int m=strlen(t);

  //どう頑張っても変更する数はmを超えないのでmで初期化
  int ans=m;

  /*
  連続するn個のボールから連続するm個(m<=n)取る方法は
  (n-m+1)通りあるからこういう範囲
  */
  for(int i=0;i<n-m+1;i++){
    //"sのここからここをtに一致させたらどうなるのか"を決める
    
    //異なっている場所がいくつあるか->変えるべき場所がいくつあるか
    int cnt=0;
    for(int j=0;j<m;j++){
      if(s[i+j]!=t[j]){
        cnt++;
      }
    }

    //答えの更新
    chmin(&ans,cnt);

    /*
    chmin自体が「もしcnt<ansならば値を更新する」という意味だから
    わざわざif(){chmin()}という書き方をしなくてもいい
    */
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1712
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int X, Y, Z;

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

  cin >> X >> Y >> Z;
  cout << Z << ' ' << X << ' ' << Y << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

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;}

signed main() {
    string s;
    cin >> s;

    rep(i, s.size()) {
        cout << "x";
    }

    return 0;
}

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

int main() {

    int N;
	string S;
    cin >> N >> S; 
	vector<ll> A(N);
	ll total = 0;
	for(int i=0;i<S.size();i++){
		S.at(i) = (S.at(i) - 'A' + N)%26 + 'A';
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        // int T;
        // T=in.nextInt();
        // while((T--)>0)
        // {
        //     //code comes here
        //     int S,W;
        //     S=in

        // }   

        int S,W;
        S=in.nextInt();
        W=in.nextInt();
        if(W>=S)
        System.out.println("unsafe");
        else
        System.out.println("safe");
    }

}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> bool chmax(T& t, const U& u) { if (t < u) { t = u; return 1; } return 0; }
template<class T, class U> bool chmin(T& t, const U& u) { if (t > u) { t = u; return 1; } return 0; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	string s; cin >> s;

	auto ok = [&](int i, int j) { //inclusive
		for (int k = i; k <= j; ++k) {
			if (s[k] != s[i+j-k]) {
				return false;
			}
		}
		return true;
	};

	int n = s.size();
	bool p = ok(0, n-1);
	bool q = ok(0, n/2-1);
	bool r = ok(n/2+1, n-1);
	puts(p && q && r ? "Yes" : "No");
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,y;
    cin >> n >> y;
    rep(i,n+1){
      rep(j,n+1-i){
        int k = n - i - j;
        if(10000*i + 5000 * j + 1000 * k == y){
          cout << i << ' ' << j << ' ' << k << "\n";
          return 0;
        }
      }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << "\n";

    return 0;
}


Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
s = input()
if c < d:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(b-1,d):
        if i+1 < len(s):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
                break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <deque>
#define MAX_N 100000
#define INF 1000000000000
typedef long long ll;
using namespace std;

int main(){
  string s,t;
  int i,ls,lt;
  bool flg;
  cin>>s>>t;
  ls=s.length();
  lt=t.length();
  for(i=ls-lt;i>=0;i--){
    flg=true;
    for(int j=0;j<lt;j++){
      if(s[i+j]=='?')continue;
      if(s[i+j]==t[j])continue;
      flg=false;
      break;
    }
    if(flg)break;
  }
  if(i<0){
    cout<<"UNRESTORABLE"<<endl;
  }else{
    for(int j=0;j<ls;j++){
      if(j>=i && j<i+lt)cout<<t[j-i];
      else if(s[j]=='?')cout<<'a';
      else cout<<s[j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var a = nexts(n);
  var ans = Array(n);
  var x = 0;
  for(var i = 1; i < n; i++)x ^= a[i];
  ans[0] = x;
  for(var i = 1; i < n; i++){
    x ^= a[i-1] ^ a[i];
    ans[i] = x;
  }
  return ans.join(" ");
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int X, A, B;
            var word = Console.ReadLine().Split(' ');
            X = int.Parse(word[0]);
            A = int.Parse(word[1]);
            B = int.Parse(word[2]);

            if (A - B >= 0)
                Console.WriteLine("delicious");
            else if (B - A > 0 && B - A <= X)
                Console.WriteLine("safe");
            else
                Console.WriteLine("dangerous");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import math
a,b,c = map(int,input().split())

h = b * math.sin(math.radians(c))
S = a * h / 2
taiga = (a ** 2) + (b ** 2) -2 * a * b * math.cos(math.radians(c))
z = math.sqrt(taiga)
L = a + b + z
print(S)
print(L)
print(h)
#print("%.10f\n%.10f\n%.10f"%(S,L,h))


Measured memory_bytes: 5704
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    string s, t;
    cin>>s>>t;
    cout<<t;
    cout<<s;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3764
use std::cmp::{Ord, Ordering, PartialOrd};
use std::io::{stdin, Read};
#[derive(PartialEq, Eq, Debug, Copy, Clone, Default, Hash)]
pub struct Reverse<T>(pub T);

impl<T: PartialOrd> PartialOrd for Reverse<T> {
    #[inline]
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }

    #[inline]
    fn lt(&self, other: &Self) -> bool {
        other.0 < self.0
    }
    #[inline]
    fn le(&self, other: &Self) -> bool {
        other.0 <= self.0
    }
    #[inline]
    fn gt(&self, other: &Self) -> bool {
        other.0 > self.0
    }
    #[inline]
    fn ge(&self, other: &Self) -> bool {
        other.0 >= self.0
    }
}

impl<T: Ord> Ord for Reverse<T> {
    #[inline]
    fn cmp(&self, other: &Reverse<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let (l, r, c): (usize, usize, i64) = parse!(it, 3);
        g[l - 1].push((r - 1, c));
    }
    for i in 0..(n - 1) {
        g[i + 1].push((i, 0));
    }

    let mut q = std::collections::BinaryHeap::new();
    let mut d = vec![std::i64::MAX / 10; n];
    d[0] = 0;
    for i in 0..n {
        q.push((Reverse(d[i]), i));
    }
    while let Some((Reverse(du), u)) = q.pop() {
        for &(v, c) in g[u].iter() {
            if d[v] > du + c {
                d[v] = du + c;
                q.push((Reverse(d[v]), v));
            }
        }
    }
    println!(
        "{}",
        if d[n - 1] == std::i64::MAX / 10 {
            -1
        } else {
            d[n - 1]
        }
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 23284
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(n*a<=b){
    System.out.println(n*a);
    }else{
    System.out.println(b);    
    }
}
}

Measured memory_bytes: 35644
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) return;
			int[][] c = new int[n][2];
			for (int i = 0; i < n; i++) {
				c[i][0] = sc.nextInt();
				c[i][1] = sc.nextInt();
			}
			int[][] dp = new int[n + 1][2001];
			dp[0][0] = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= 1000; j++) {
					if (dp[i][j] != 0) {
						dp[i + 1][j] += dp[i][j];
						for (int k = 1; k <= c[i][1]; k++) {
							if (j + k * c[i][0] <= 1000) dp[i + 1][j + k * c[i][0]] += dp[i][j];
						}
					}
				}
			}
			int m = sc.nextInt();
			while (m-- > 0) {
				System.out.println(dp[n][sc.nextInt()]);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,s=0;
cin>>a>>b;
if(a>=b){
	s+=a;
	a--;
}
else{
	s+=b;
	b--;
}
if(a>=b){
	s+=a;
	a--;
}
else{
	s+=b;
	b--;
}
cout<<s;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(x-r>=0&&y-r>=0&&y+r<=H&&x+r<=W)
      printf("Yes\n");
    else
	  printf("No\n");
    return 0;
}

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

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

  rep(i, S.size())
  {
    int moji = (S[i] + N - 'A') % 26;
    char c = 'A' + moji;
    cout << c;
  }
  cout << endl;
  return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;
const double PI = std::acos(-1.0);
const double q = PI * 5.0 - 20;
const double h = PI * 10.0 - 20;

namespace Problem {
using namespace std;

class Solver {
 public:
  LL sx, sy, gx, gy, n;
  vector<pair<int, int>> p;
  void solve() {
    cin >> sx >> sy >> gx >> gy >> n;
    double ans = (double)(abs(sx - gx) + abs(sy - gy)) * 100;
    for (int i = 0; i < n; ++i) {
      int xx, yy;
      cin >> xx >> yy;
      if ((sx - xx) * (gx - xx) <= 0 && (sy - yy) * (gy - yy) <= 0) {
        p.emplace_back(xx, yy);
      }
    }
    //p.emplace_back(sx, sy);
    //p.emplace_back(gx, gy);
    if (gx < sx) {
      sx = 100000000 - sx;
      gx = 100000000 - gx;
      for (int i = 0; i < p.size(); ++i) {
        p[i].first = 100000000 - p[i].first;
      }
    }
    if (gy < sy) {
      sy = 100000000 - sy;
      gy = 100000000 - gy;
      for (int i = 0; i < p.size(); ++i) {
        p[i].second = 100000000 - p[i].second;
      }
    }
    sort(p.begin(), p.end());
    vector<int> Y;
    for (auto &&x : p) {
      Y.push_back(x.second);
    }
    DBG(Y)
    int res = LIS(Y);
    DBG(res)
    //res -= 2;
    if (res == min(abs(sx - gx), abs(sy - gy)) + 1) {
      cout << ans + (res - 1) * q + h << endl;
    } else {
      cout << ans + res * q << endl;
    }
  }
  int LIS(const vector<int> &a) {
    if (a.size() == 0) return 0;
    const int n = a.size();
    vector<int> A(n, 1 << 30);
    vector<int> id(n);
    for (int i = 0; i < n; i++) {
      id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
      A[id[i]] = a[i];
    }
    int m = *max_element(id.begin(), id.end());
    return m + 1;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


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

using namespace std;

const long long mod = 1ll * 1000 * 1000 * 1000 + 7;

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

    int n;
    cin >> n;
    long long ans = 1;
    long long first_allowed = 0;
    long long free_pos = 1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        cerr << first_allowed << ' ' << free_pos << endl;
        ans = (ans * ((i + 1)*1ll - first_allowed)) % mod;
        if (x >= free_pos) {
            free_pos += 2;
        } else {
            first_allowed += 1;
            free_pos = x + 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals("+")) System.out.println(a + b);
			else if (op.equals("-")) System.out.println(a - b);
			else if (op.equals("*")) System.out.println(a * b);
			else if (op.equals("/")) System.out.println(a / b);
			else if (op.equals("?")) break;
		}
	}
}

Measured memory_bytes: 26020
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


signed main(){
    string s;
    cin >> s;
    bool rl = true;
    vec(a,s.size());
    int cnt = 0;
    int tmp;
    REP(i,s.size()-1){
        if(s[i] == s[i+1]){
            cnt++;
        }
        else{
            cnt++;
            //print(cnt)
            if(rl){
                tmp = i;
                if(cnt%2==0){
                    a[i] = cnt / 2;
                    a[i+1] = cnt / 2;
                }
                else{
                    a[i] = (cnt / 2)+1;
                    a[i+1] = cnt / 2;
                }
                rl = false;
            }
            else{
                if(cnt%2==0){
                    a[tmp] += cnt / 2;
                    a[tmp+1] += cnt / 2;
                }
                else{
                    a[tmp] += cnt / 2;
                    a[tmp+1] += (cnt / 2)+1;

                }
                rl = true;
            }
            
            cnt = 0;
        }
       // Debug(a);
    }
    cnt++;
    if(cnt%2==0){
        a[tmp] += cnt / 2;
        a[tmp+1] += cnt / 2;
    }
    else{
        a[tmp] += cnt / 2;
        a[tmp+1] += (cnt / 2)+1;

    }
    Debug(a);
    return 0;
}

void Debug(auto a){
    //cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    //cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 2176
#include<stdio.h>
int divisor(int n){
    int a = 0;
    for(int i = 1; i <= n; i= i+2){
        if(n%i == 0){
            a++; 
        }
    }
    return a;
}

int main(void){
    int N;
    int n = 0;
    scanf("%d",&N);
    if(N>=105){
        for(int i  =105; i <= N; i=i+2){
            if(divisor(i) == 8){
                n++;
                // printf("i = %d, div = %d\n",i, divisor(i));
            }
        }
    }
    printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;

int hitei(int a){
  return (2-a);
}

int whereis(string s){
  int i=0;
  bool kakko = false;
  int continuing = 0;
  while(true){
    if((s[i]=='*' || s[i]=='+') && (!kakko)){
      return i;
    }else if(s[i]=='('){
      kakko=true;
      continuing++;
    }else if(s[i]==')'){
      continuing--;
      kakko=(continuing!=0);
    }
    i++;
  }
}

int calc(string s){
  switch(s[0]){
  case '(':
    {
      string kakkohazushi = s.substr(1,s.length()-2);
      int enzanshi = whereis(kakkohazushi);
      if(kakkohazushi[enzanshi]=='*'){
	return min(calc(kakkohazushi.substr(0,enzanshi)),calc(kakkohazushi.substr(enzanshi+1,kakkohazushi.length()-enzanshi-1)));
      }else{
	return max(calc(kakkohazushi.substr(0,enzanshi)),calc(kakkohazushi.substr(enzanshi+1,kakkohazushi.length()-enzanshi-1)));
      }
    }
    break;
  case '-':
    return hitei(calc(s.substr(1,s.length()-1)));
    break;
  default:
    return (int)(s[0]-'0');
  }
}

int main(){
  while(true){
    string s;
    cin >> s;
    if(s==".") break;
    int count = 0;
    rep(p,3){
      rep(q,3){
        rep(r,3){
	  string a = s;
	  replace(a.begin(),a.end(),'P',to_string(p)[0]);
	  replace(a.begin(),a.end(),'Q',to_string(q)[0]);
	  replace(a.begin(),a.end(),'R',to_string(r)[0]);
	  if(calc(a)==2) count++;
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	ll arr[n];ll lala[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		lala[i]=arr[i];
	}
	sort(arr,arr+n);
	
	for(ll i=0;i<n;i++){
		if(arr[n-1]==lala[i])cout<<arr[n-2]<<nw;
		else cout<<arr[n-1]<<nw;
	}

}

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

ll inf = 1e18;

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> H(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> H[i];
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, inf)); //dp[i][j] = i個塗ってjを最後とする
    dp[0][0] = 0;
    
    if (N == K) {
        cout << 0 << endl;
        return 0;
    }
    
    for (int i = 1; i <= N; i++) {
        for (int j = i; j >= 1; j--) {
            for (int k = 0; k <= i-1; k++) {
                dp[j][i] = min(dp[j][i], dp[j-1][k]+max((ll)0, H[i]-H[k]));
            }
        }
    }
    ll ans = 1e18;
    for (int i = N-K; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            ans = min(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, count;
  cin >> N >> M;
  
 vector<int> vec(2*M);
 for (int i=0;i<2*M;i++){
   cin >> vec.at(i);
 }
  
  for (int i=1;i<N+1;i++){
    count = 0;
    for (int j=0;j<2*M;j++){ 
     if (vec.at(j) == i){
      count++;
     }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#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		main(void)
{
	int		W;
	int		H;
	int		N;
	cin >> W >> H >> N;
	int		cnt = 0;

	vector<vector<int>> xya(N, vector<int> (3));
	vector<vector<int>> field(W, vector<int> (H, 0));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 3; j++)
			cin >> xya.at(i).at(j);
	}
	for (auto &&i : xya)
	{
		if (i.at(2) == 1)
		{
			for (int j = 0; j < i.at(0); j++)
			{
				for (auto &k : field.at(j))
					k = 1;
			}
		}
		else if (i.at(2) == 2)
		{
			for (int j = i.at(0); j < W; j++)
			{
				for (auto &k : field.at(j))
					k = 1;
			}
		}
		else if (i.at(2) == 3)
		{
			for (auto &j : field)
			{
				for (int k = 0; k < i.at(1); k++)
					j.at(k) = 1;
			}
		}
		else
		{
			for (auto &j : field)
			{
				for (int k = i.at(1); k < H; k++)
					j.at(k) = 1;
			}
		}
	}
	for (int i = 0; i < W; i++)
	{
		for (auto &j : field.at(i))
		{
			if (!j)
				cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []a = new int [m];
		boolean []jdg = new boolean [n+1];
		long []Dp = new long [n+1];
		int p = 1000000007;
		
		for(int i = 0; i < m ; i++) {
			a[i] = sc.nextInt();
			jdg [a[i]] = true;
		}
		Dp[0] = 1;
		
		for(int i = 1 ; i <= n; i++) {
			if(jdg[i] == false) {
			 if(i == 1)
				Dp[i] = Dp[i -1];
			 if(i >= 2) {
				 Dp[i] = (Dp[i-1])%p+(Dp[i-2])%p;
			     Dp[i] = Dp[i]%p;
			}
		}
			if(jdg[i] == true) {
				Dp[i] = 0;
			}
		
		}
		System.out.println(Dp[n]);
	}
		
}




Measured memory_bytes: 50192
def solve(lis,N):
    x=(lis[0][0]+lis[N//2][0])
    y=(lis[0][1]+lis[N//2][1])
    for i in range(1,N//2):
        if (lis[i][0]+lis[i+N//2][0])!=x or (lis[i][1]+lis[i+N//2][1])!=y:
            return "NA"
    return str(x/2)+" "+str(y/2)

N=int(input())
if N%2==1:
    print("NA")
else:
    lis=[]
    for i in range(N):
        lis.append(tuple(map(int,input().split())))
    ans=solve(lis,N)
    print(ans)



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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    int city[n] = {0};
    for(int i=0; i<m; i++) {
        cin >> a[i] >> b[i];
    }
    set<int> sa(a.begin(), a.end()), sb(b.begin(), b.end());
    
    for(auto itr=sa.begin(); itr!=sa.end(); itr++){
        city[*itr-1] += std::count(a.begin(), a.end(), *itr);
    }
    for(auto itr=sb.begin(); itr!=sb.end(); itr++){
        city[*itr-1] += std::count(b.begin(), b.end(), *itr);
    }
    for(int i=0; i<n; i++){
        cout << city[i] << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    ll n, r=0, g=0, b=0;
    string s;
    cin >> n >> s;
    for(char c : s){
        if(c == 'R') r++;
        if(c == 'G') g++;
        if(c == 'B') b++;
    }
    ll ans = r * g * b;
    ll count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(s[i] == s[j]) continue;
            int k = 2 * j -i;
            if(k >= n || s[i] == s[k] || s[k] == s[j]) continue;
            count++;
        }
    }
    cout << ans - count << endl;
    return 0;
}

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


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

	int i=0;
	int time = 0;
	while(true){
		//cout << "i:" << i << "\ttime:" << time << endl;
		if(x == time){
			break;
		}
		if(x < time){
			time -= i;
			i--;
		}else{
			time += i;
			i++;
		}
	}
	cout << i-1 << endl;
}


Measured memory_bytes: 888