akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N;
	cin >> N;
	vector<ll> ans;
	if (N == 3) {
		ans = {2,5,63};
	} else if (N == 4) {
		ans = {2,5,20,63};
	} else {
		while (ans.size() < N) {
			ll cnt = ans.size();
			vector<ll> add;
			if (N - cnt == 1) {
				add = {6};
			} else if (N - cnt == 2) {
				add = {2,4};
			} else if (N - cnt == 3) {
				add = {2,4,6};
			} else if (N - cnt == 4) {
				add = {2,4,8,10};
			} else if (N - cnt == 5) {
				add = {2,3,6,9,10};
			} else if (N - cnt == 6) {
				add = {2,3,6,9,10,12};
			} else if (N - cnt == 7) {
				add = {2,3,4,6,8,9,10};
			} else {
				add = {2,3,4,6,8,9,10,12};
			}
			for (ll n : add) {
				ans.push_back(cnt / 8 * 12 + n);
			}
		}
	}
	for (ll i = 0; i < N; i++) {
		cout << ans[i];
		if (i < N - 1) {
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define power 210000
int rm[power]={},rp[power]={};
void Initialize(int c){
    rm[0]=1;
    rp[0]=1;
    for(int i=1;i<power;i++){
        rm[i]=(rm[i-1]*2)%(c-1);
        rp[i]=(rp[i-1]*2)%(c+1);
    }
}
int main(){
    int n;
    string s;
    cin>>n>>s;
    int c=0;
    for(int i=0;i<n;i++)if(s[i]=='1')c++;
    if(c==0){
        for(int i=0;i<n;i++){
            cout<<1<<endl;
        }
        return 0;
    }
    if(c==1){
        if(s[n-1]=='1'){
            for(int i=0;i<n-1;i++){
                cout<<2<<endl;
            }
            cout<<0<<endl;
        }else{
            for(int i=0;i<n-1;i++){
                if(s[i]=='1'){
                    cout<<0<<endl;
                    continue;
                }
                cout<<1<<endl;
            }
            cout<<2<<endl;
        }
        return 0;
    }
    Initialize(c);
    int val_minus=0,val_plus=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            val_minus+=1;
            val_plus+=1;
        }
        val_minus%=c-1;
        val_plus%=c+1;
        if(i==n-1)break;
        val_minus*=2;
        val_plus*=2;
    }
    int ans[power]={};
    for(int i=1;i<power;i++){
        int count=0;
        for(int j=0;j<20;j++){
            if(i&(1<<j))count++;
        }
        ans[i]=ans[i%count]+1;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            int rest=val_minus-rm[n-1-i];
            rest+=c-1;
            rest%=c-1;
            cout<<ans[rest]+1<<endl;
        }else{
            int rest=val_plus+rp[n-1-i];
            rest%=c+1;
            cout<<ans[rest]+1<<endl;
        }
    }
}


Measured memory_bytes: 6208
#include <stdio.h>
#define  MAX 101


struct Dis
{
    int pa[MAX];
    int used[MAX];
    int n;
    Dis(int n):n(n)
    {
        for(int i=0;i<n;i++)
        {
            pa[i]=i;
            used[i]=0;
        }
    }
    void use(int i)
    {
        used[i]=1;
    }
    int root(int a)
    {
        if(pa[a]==a)
            return a;
        return pa[a]=root(pa[a]);
    }
    bool is_same_set(int a,int b)
    {
        return root(a)==root(b);
    }
    void unite(int n,int m)
    {
        use(n);
        use(m);
        pa[root(n)]=root(m);
    }
    bool is_connected()
    {
        int rt=-1;
        for(int i=0;i<n;i++)
        {
            if(rt>=0 &&used[i] && rt!=root(i))
                return false;
            if(used[i])
                rt=root(i);
        }
        return rt!=-1;
    }
};

int br[6000][3];

int getMin(int m)
{
    int tmp=-1;
    for(int i=0;i<m;i++)
    {
        if(br[i][2]!=-1)
        {
            if(tmp==-1 || br[tmp][2]>br[i][2])
            {
                tmp=i;
            }
        }
    }
    if(tmp!=-1)
    {
        return tmp;
    }
    return -1;
}

int main(void)
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2 && n && m)
    {
        Dis dis(n);
        for(int i=0;i<m;i++)
        {
            scanf("%d%d%d",br[i],br[i]+1,br[i]+2);
        }
        int nc=0;
        int cost=0;
        while(nc<n-1)
        {
            int min=getMin(m);
            if(min==-1)
            {
                puts("min=-1");
            }
            int a=br[min][0];
            int b=br[min][1];
            if(!dis.is_same_set(a,b))
            {
                dis.unite(a,b);
                nc++;
                cost+=br[min][2];
            }
            br[min][2]=-1;
        }
        printf("%d\n",cost);
    }
    return 0;
    
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    double x;
    cin>>x;
    int c=0;
    double p=100.0;
    while(p<x)
    {
        double interest=p*0.01;
        interest=floor(interest);
        p+=interest;
        c++;
    } 
    cout<<c;    
    return 0;
}

Measured memory_bytes: 3756
N = int(input())
lst = []

for _ in range(N):
  lst.append(list(map(int, input().split())))

for l in lst:
  if l[0] % 2 != (abs(l[1]) + abs(l[2])) % 2 or (abs(l[1]) + abs(l[2])) > l[0]:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 27300
#include<iostream>
#include<vector>
using namespace std;
int needx[]={-1,0,1,0,1,1,-1,-1};
int needy[]={0,1,0,-1,1,-1,1,-1};
//テ・ツウツカテ」ツつ津・ツ?ィテ」ツ?ヲfalseテ」ツ?ォテ・ツ、ツ嘉」ツ?暗」ツ?ヲtrueテ」ツつ津ィツソツ氾」ツ?凖ゥツ鳴「テヲツ閉ー//
bool land(int x,int y,vector<vector<bool> >& cango){
    if(cango[x][y]){
        cango[x][y]=false;
        for(int i=0;i<8;i++){
            int nextx=x+needx[i];
            int nexty=y+needy[i];
            if(cango[nextx][nexty])
                bool flag=land(nextx,nexty,cango);
            }
    return true;
     }else{
return false;
    }
}
int main(void){
    int input;
	int w,h;
	while(1){
cin>>w>>h;
if(h==0)break;
    vector<vector<bool> > cango(h+2,vector<bool>(w+2,false));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >>input;
            if(input==1){
cango[i][j]=true;
            }
        }
    }
  
    int t=0;
for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        if(land(i,j,cango)){
            t++;
        }
    }
}
cout <<t<<endl;
	}
return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
int main(){
	int H,W,tate,yoko;
	for(;;){
		scanf("%d %d",&H,&W);if(H==0&&W==0){break;}
	for(tate=1;tate<=H;tate++){
		for(yoko=1;yoko<=W;yoko++){
				if(2<=tate&&tate<=H-1&&2<=yoko&&yoko<=W-1){printf(".");
		}else{printf("#");}
			
		}printf("\n");
		}printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
n = int(input())
s = list(input())
ln = len(s)
alph = [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z",
]

ans = []
for i in range(ln):
    ind = alph.index(s[i])
    newind = ind + n
    if newind > 25:
        newind = newind - 26
    ans.append(alph[newind])

print("".join(ans))


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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

    int N, K;
    cin >> N >> K;

    int half = -1;
    for (int r = 1; r < K; r++) {
        if ((r + r) % K == 0) {
            half = r;
            break;
        }
    }

    ll zc = 0, hc = 0;
    for (int i = 1; i <= N; i++) {
        if (i % K == 0) zc++;
        if (i % K == half) hc++;
    }

    cout << zc * zc * zc + hc * hc * hc << endl;

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    int l = max(c,d);
    for(int i = min(a,b);i < l;i++)
    {
        if(s[i] == s[i - 1] && s[i] == '#')
        {
            cout << "No\n";
            return 0;
        }
    }
    if(d < c)
    {
        for(int i = b;i <= d;i++)
        {
            if(s[i] == s[i - 1] && s[i - 1] == s[i - 2] && s[i] == '.')
            {
                cout << "Yes\n";
                return 0;
            }
        }
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n % 2 != 0) {
    puts("No");
    return 0;
  }
  int l = n / 2;
  string a = s.substr(0, l);
  string b = s.substr(l, n);
  if (a == b) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200;
int ai[N], vi[N], mx;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> ai[i], mx = max(mx, ai[i]), vi[ai[i]] ++;
    if (mx & 1)
    {
        for (int i = mx; i > mx / 2; -- i) if (vi[i] < 2) return puts("Impossible"), 0;
        if (vi[mx / 2 + 1] != 2) return puts("Impossible"), 0;
        for (int i = mx / 2; ~i; -- i) if (vi[i]) return puts("Impossible"), 0;
    }
    else
    {
        for (int i = mx; i > mx / 2; -- i) if (vi[i] < 2) return puts("Impossible"), 0;
        if (vi[mx / 2] != 1) return puts("Impossible"), 0;
        for (int i = mx / 2 - 1; ~i; -- i) if (vi[i]) return puts("Impossible"), 0;
    }
    puts("Possible");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] c = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            if(max < c[i]) max = c[i];
        }
        long mod = 1_000_000_007L;
        long[] cnt = new long[max+1];
        long[] sum = new long[n];
        long[] presum = new long[max+1];
        long ans = 0L;
        cnt[c[0]]++;
        for (int i = 1; i < n; i++) {
            if(c[i] == c[i-1]){
                sum[i] = sum[i-1];
                continue;
            }
            ans = (ans + cnt[c[i]]) % mod;
            ans = (ans + presum[c[i]]) % mod;
            cnt[c[i]]++;
            sum[i] = ans;
            presum[c[i]] = (presum[c[i]] + sum[i-1]) % mod;
        }
        System.out.println(ans+1);
        sc.close();

    }

}


Measured memory_bytes: 74984
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		
		if (x < a ) {
			System.out.print("0");
		}else{
			System.out.print("10");
		}
		
	}
}

Measured memory_bytes: 21844
@n, @q = gets.chomp.split.map(&:to_i)
@ab = {}
(@n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  @ab[b] = a
end
@qx = {}
@q.times do
  q, x = gets.chomp.split.map(&:to_i)
  if @qx.has_key?(q) then
    @qx[q] += x  
  else
    @qx[q] = x  
  end
end
#
@r = Array.new(@n)
@r[0] = (@qx.has_key?(1) ? @qx[1] : 0)
def calc(i)
  if @r[i-1] then
    return @r[i-1]
  end
  return @qx.has_key?(i) ? @qx[i] + calc(@ab[i]) : calc(@ab[i])
end
2.upto(@n) do |i|
  @r[i-1] = calc(i)
end
puts @r.map(&:to_s).join(" ")

Measured memory_bytes: 43900
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int n,m;
long long a[10],c,b[6];
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	cin>>s;
	if(s[0]=='M')a[1]++;
	if(s[0]=='A')a[2]++;
	if(s[0]=='R')a[3]++;
	if(s[0]=='C')a[4]++;
	if(s[0]=='H')a[5]++;
	}
	c=1ll;
	for(int i=1;i<=5;i++)
	{
	if(a[i]>0)m++;
	}
	if(m==1)cout<<0;
	else 
	{
	c=a[1]*a[2]*(a[3]+a[4]+a[5])+a[1]*a[3]*(a[4]+a[5])+a[1]*a[4]*a[5]+a[2]*a[3]*(a[4]+a[5])+a[2]*a[4]*a[5]+a[3]*a[4]*a[5];
	cout<<c;	 	
	}
	return 0;
}

Measured memory_bytes: 256
Base = [[1, 2, 3, 4, 5, 6], [1, 3, 5, 2, 4, 6], [1, 5, 4, 3, 2, 6], [1, 4, 2, 5, 3, 6], [5, 1, 3, 4, 6, 2], [5, 3, 6, 1, 4, 2], [5, 6, 4, 3, 1, 2], [5, 4, 1, 6, 3, 2], [6, 5, 3, 4, 2, 1], [6, 3, 2, 5, 4, 1], [6, 2, 4, 3, 5, 1], [6, 4, 5, 2, 3, 1], [2, 6, 3, 4, 1, 5], [2, 3, 1, 6, 4, 5], [2, 1, 4, 3, 6, 5], [2, 4, 6, 1, 3, 5], [4, 1, 5, 2, 6, 3], [4, 5, 6, 1, 2, 3], [4, 6, 2, 5, 1, 3], [4, 2, 1, 6, 5, 3], [3, 5, 1, 6, 2, 4], [3, 1, 2, 5, 6, 4], [3, 2, 6, 1, 5, 4], [3, 6, 5, 2, 1, 4]]

class Dice

def initialize(arr)
@all = []
Base.each{|b|
temp = Array.new(6)
for j in 1..6
temp[j-1] = arr[ b[j-1] -1 ]
end
@all.push(temp)
}
@all.sort!
end

def getfirst()
    return @all[0]
  end

end


n = gets.to_i

sample = []
for j in 1..n
sample.push(Dice.new(gets.split.map(&:to_i)).getfirst())
end

flag = false

for i in 1..(n-1)
for j in 0..(i-1)

if sample[i] == sample[j] then
flag = true
break
end

end

if flag == true then
break
end

end

if flag == true then
puts "No"
else
puts "Yes"
end









Measured memory_bytes: 7024
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;


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

      int n; cin >> n;
      map<string,int> mp;
      string s;
      rep(i,n){
          cin >> s;
          mp[s] = 1;
      }

      int ans = 0;
      for(auto x: mp){
          ans++;
      }

      cout << ans << endl;


      return 0;
}


Measured memory_bytes: 19248
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string N;
	std::cin >> N;
	if (N[0] == N[1] && N[1] == N[2]) {
		std::cout << "Yes" << '\n';
	}
	else if (N[1] == N[2] && N[2] == N[3]) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int gcd(int x, int y)
{//precondition : 1 <= x,y <=10^9
    int a = max(x,y), b = min(x,y);
    //invariant : gcd(a,b) = gcd(x,y) && a >= b
    while(a != b)
    {
        int tmp = a - b;
        a = max(tmp,b);
        b = min(tmp,b);
    }
    return a;
//postcondition : return res as gcd    
}

int main()
{
    int a = -1, b = -1;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3096
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define endl '\n'
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define clr(v,val) memset(v,val,sizeof(v))
#define rep(i,m,n) for(int i=m ; i<n ; i++)
#define forr(i,m,n) for(int i=m ; i<=n ; i++)
#define pb push_back
#define pff push_front
#define re return
#define bit __builtin_popcountll
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 10;
using namespace std;
int main(){
    IO;
    int n;
    cin>>n; vector<pii>v;
    forr(i,1,n){
   int x; cin>>x;
    v.pb({x,i});
    }
    sort(all(v));
    for(auto i:v){
        cout<<i.second<<" ";
    }


}


Measured memory_bytes: 1780
#include <iostream>

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

int main() {
  int K;
  std::cin >> K;

  int sum = 0;

  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        sum += gcd(gcd(a, b), c);
      }
    }
  }
  std::cout << sum << '\n';
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((a+b)>(c+d)){
        cout<<"Left";
    }else if ((a+b)==(c+d)){
        cout<<"Balanced";
    }else cout<<"Right";
    return 0;
}


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

const int MAX = 510000;
const int mod = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    while(n){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>



const int MAX_V = 1000000;
int prime[1000001];



int main(){
    int i,k,n;
    int cnt = 0;
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    
    for(i = 2; i*i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i; k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    
    
    while(scanf("%d", &n) != EOF){
      cnt = 0;
      for(i = 2; i <= n; i++){
        if(prime[i] == 1){
            cnt++;
        }
      }
      printf("%d\n", cnt);
    }
    return 0;
}

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

namespace ABC175C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long X = long.Parse(input[0]);
            long K = long.Parse(input[1]);
            long D = long.Parse(input[2]);
            if (X < 0)
            {
                X *= -1;
            }
            if (X == 0)
            {
                if (K % 2 == 0)
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(D);
                }
            }
            else
            {
                if (K <= X / D)
                {
                    Console.WriteLine(X - D * K);
                }
                else
                {
                    long amari = X % D;
                    long count = ((X - amari) / D) + 1;
                    long temp = X - (D * count);
                    if ((K - count) % 2 == 0)
                    {
                        Console.WriteLine(temp * (-1));
                    }
                    else
                    {
                        Console.WriteLine(temp + D);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 27464
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
const int mod=1e9+7;
using namespace std;
int n,k,f[110][33000][2],sum[110][33000][2],m;
int main()
{
	scanf("%d %d",&n,&k);
	m=sqrt(n);
	//printf("%d %d %d\n",m,n/m,n/(m+1));
	for(int i=0;i<=m;i++) sum[0][i][0]=1;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=m;j++) f[i][j][0]=(sum[i-1][m][0]+(sum[i-1][m][1]-sum[i-1][j-1][1])%mod)%mod;
		int j=m+1,r;
		while(j<=n)
		{
			r=n/(n/j);int t=n/j;
			//printf("%d %d\n",j,r);
			//if(n/j==n/(r+1)) printf("fuck\n");
			f[i][t][1]=(LL)(sum[i-1][t][0])*(r-j+1)%mod;
			j=r+1;
		}
		//printf("--------------------\n");
		for(int j=1;j<=m;j++)
		{
			sum[i][j][0]=(sum[i][j-1][0]+f[i][j][0])%mod;
			sum[i][j][1]=(sum[i][j-1][1]+f[i][j][1])%mod;
			//printf("%d %d\n",f[i][j][0],f[i][j][1]);
		}
	}
	int ans=(sum[k][m][0]+sum[k][m][1])%mod;
	printf("%d",(ans+mod)%mod);
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
string S;
cin >> S;
int ans = 700;
REP(i, 3) if(S[i] == 'o') ans += 100;

print(ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static double minkDist(int[] a, int[] b, int n, int p){
		double result = 0;
		
		double max = 0;
		for(int i = 0; i < n; i++){
			result += Math.pow(Math.abs(a[i] - b[i]), p);
			
			if(max < Math.abs(a[i] - b[i])){
				max = Math.abs(a[i] - b[i]);
			}
		}
		
		if(p == Integer.MAX_VALUE){
			return max;
		}
		else {
			return Math.pow(result, 1.0/p);
		}
	}
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


//		String str = br.readLine();

//		while(true){
		int n = Integer.parseInt(br.readLine());

		int[] a = new int[n];
		int[] b = new int[n];

		String[] tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(tmpArray[i]);
		}

		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			b[i] = Integer.parseInt(tmpArray[i]);
		}
		
		System.out.println(minkDist(a, b, n, 1));
		System.out.println(minkDist(a, b, n, 2));
		System.out.println(minkDist(a, b, n, 3));
		System.out.println(minkDist(a, b, n, Integer.MAX_VALUE));
		
//
//			if(n == 0){
//				break;
//			}
//			String[] tmpArray = br.readLine().split(" ");
//			int[] input = new int[n];
//			int sum = 0;
//			for(int i = 0; i < n ; i++){
//				input[i] = Integer.parseInt(tmpArray[i]);
//				sum += input[i];
//			}
//			double ave = (double)sum / n;
//
//			double var = 0;
//			for(int i = 0; i < n ; i++){
//				var += Math.pow((input[i] - ave) , 2)/n;
//			}
//
//			System.out.println(Math.pow(var, 0.5));
//		}
//		System.out.println(p1.distance(p2));


//		System.out.println(count);

//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24560
n,k = tuple(map(int,input().split())) 
N = list(map(int,input().split()))
s = sum(N[0:k])
m = sum(N[0:k])

for i in range(0,n-k):
    s = s-N[i]+N[i+k]
    m = max(m,s)   
print((m+k)/2)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll a1;
    ll a2;
    ll a3;

    string ans = "win";

    cin >> a1 >> a2 >> a3;

    if(a1 + a2 + a3 >= 22){
        ans = "bust";
    }
    
    cout << ans <<  endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, p = 0, d = 0;
    scanf("%d\n", &n);
    vector<char> s(n);
    scanf("%s", s.begin());
    for (int i = 0; i < n; ++i) switch (s.at(i)) {
        case '(': ++d; break;
        case ')': if (d == 0) ++p; else --d; break;
    }
    for (int i = 0; i < p; ++i) printf("(");
    printf("%s", s.begin());
    for (int i = 0; i < d; ++i) printf(")");
    printf("\n");
    return 0;
}


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


int main(){
    int h1,m1,h2,m2,k;
    cin >>h1>>m1>>h2>>m2>>k;
    int len = h2*60 + m2 -h1*60 -m1 -k;
    cout << len << endl;
    return 0;
}


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

typedef pair <double,int>  PDI;
int n,l;
double s;
deque <PDI> Q;
PDI x;

void work()
{
	scanf("%d %d",&n,&l);
	double t;
	for (int i=1,r,v; i<=n; i++)
		{
			scanf("%lf %d",&t,&v),s+=t*v,r=(i==1?0:v);
			while (r)
				{
					x=Q.front(),Q.pop_front();
					s-=x.first*min(r,x.second);
					if (r<x.second)  x.second-=r,r=0,Q.push_front(x);
					else  r-=x.second;
				}
			while ((!Q.empty())&&(Q.back().first>=t))
				x=Q.back(),Q.pop_back(),t=(t*v+x.first*x.second)/(v+x.second),v+=x.second;
			Q.push_back(make_pair(t,v));
			printf("%.7lf\n",s/l);
		}
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 17168
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[19];
	scanf("%s",s);
	
	if((s[5]==',')&&(s[13]==',')){
	
	s[5]=' ';
	s[13]=' ';
}
printf("%s",s);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    int n,k,x,y,ans=0;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    for(int i=1;i<=n;i++){
        if(i<=k)ans+=x;
        else ans+=y;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	string S; cin >> S;
	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		for (int j = i + 1; j < 4; ++j) {
			if (S[i] == S[j]) {
				ans++;
			}
		}
	}
	if (ans == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
li = list(map(int,input().split()))	
ruiseki=[0]*(n+1)
for i in range(n):
    ruiseki[i+1]=ruiseki[i]+li[i]
ans=0
for i in range(0,n-1):
    ans+=(li[i]*(ruiseki[-1]-ruiseki[i+1]))%((10**9)+7)
print(ans%((10**9)+7))

Measured memory_bytes: 105372
def main():
    MOD = 10 ** 9 + 7
    S = input()
    u = [1] + [0] * 12
    v = [0] * 13
    m = 1
    shift = 0
    for s in reversed(S):
        if s == '?':
            for j in range(13):
                v[j] = sum(u[(j - (m * i) % 13) % 13] for i in range(10)) % MOD
            u, v = v, u
        else:
            shift = (shift + m * int(s)) % 13
        m = m * 10 % 13
    return u[(5 - shift) % 13]

print(main())


Measured memory_bytes: 43484
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int ans=0;
  string s;
  cin>>s;
  rep(i,3){
    if(s[i]=='1')ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

vector<string>grid;
string memo[70][70];
bool comp(const string& s1, const string& s2)
{
	if (s1.size() == s2.size())
	{
		return s1 < s2;
	}
	return s1.size() < s2.size();
}
string dp(int i, int j)
{
	if (i < 0 || j < 0)return "";
	if (memo[i][j] != "-1")return memo[i][j];
	string s = "";
	if (!isalpha(grid[i][j]))
	{
		string s1 = dp(i - 1, j);
		string s2 = dp(i, j - 1);
		if (comp(s1, s2))
		{
			s = s2;
		}
		else
		{
			s = s1;
		}
		s.push_back(grid[i][j]);
	}
	while (!s.empty() && s.front() == '0')s.erase(s.begin(), s.begin() + 1);
	return memo[i][j] = s;
}

int main(void)
{
	int w, h;
	for (;;)
	{
		cin >> w >> h;
		if (!w)break;
		grid.clear();
		for (int i = 0; i < h; ++i)
		{
			string c;
			cin >> c;
			grid.push_back(c);
			for (int j = 0; j < w; ++j)
			{
				memo[i][j] = "-1";
			}
		}
		string ans;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				string s = dp(i, j);
				if (comp(ans, s))
				{
					ans = s;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <map>

using namespace std;
using ll = long long int;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto K = RD;
	auto T = RD;
	auto A = RDA;
	auto heap = heapify(A);
	while (heap.length >= 2)
	{
		auto x = heap.front; heap.removeFront;
		auto y = heap.front; heap.removeFront;
		if (x != 1)
			heap.insert(x-1);
		if (y != 1)
			heap.insert(y-1);
	}

	long ans;
	if (!heap.empty)
	{
		ans = heap.front - 1;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<iomanip>
#include<cctype>
#include<cstdio>
#include<deque>
#include<utility>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define INF 1000000000
#define ll long long
#define RE register
#define a(i) s[i].A
#define b(i) s[i].B
#define c(i) s[i].C
#define id(i) s[i].id
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const int MAXN=110;
int n,ans=INF;
int a[MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=100;++i)
	{
		int cnt=0;
		for(int j=1;j<=n;++j)
		{
			cnt+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import Data.List (subsequences)

main:: IO ()
main = do
    [n,p] <- (map read . words) <$> getLine
    as <- (map read . words) <$> getLine
    print $ solve n p as

-- |
--
-- >>> solve 2 0 [1,3]
-- 2
--
solve :: Integer -> Integer -> [Integer] -> Integer
solve n p xs = kO * kE
  where
    numOdds = fromIntegral $ length . filter odd $ xs
    numEvens = n - numOdds
    kE = 2 ^ numEvens
    kO = sum [numOdds `ncr` x | x <- [0 .. numOdds], x `mod` 2 == p]

ncr :: Integer -> Integer -> Integer
ncr n r = fact n `div` (fact r * fact (n-r))

fact :: Integer -> Integer
fact 0 = 1
fact 1 = 1
fact x = x * fact (x-1)


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    string n;
    cin >> n;
    char num = n.back();
    if (num == '3') {
        cout << "bon" << endl;
    }else if (num == '0' || num == '1' || num == '6' || num == '8') {
        cout << "pon" << endl;
    }else {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	ll N, T;
	cin >> N >> T;
	vector<ll> t(N);
	rep(i, N) cin >> t[i];

	ll ans = 0;
	ans = T + t[N-1];
	rep(i, N-1) {
		ans -= max(0LL, (t[i+1]-t[i]-T));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int n;
	ll ans=0;
	string s,t;
	map<string,ll>m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	for (auto i = m.begin(); i != m.end(); ++i) 
	{
		ans+=(i->second)*(i->second-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
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 n = int.Parse(Console.ReadLine());
            bool flag = false;


            for (int i = 0; 4*i <= n; i++)
            {
                for(int j = 0; j*7 <= n; j++)
                {
                    if (n == 4 * i + 7 * j)
                        flag = true;
                }
            }

            if (flag)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }
}

Measured memory_bytes: 11092
void wt(int x)
{
	int s=0;
	char f[10];
	while(x)
	{
		f[s++]=x%10;
		x/=10;
	}
	if(!s)f[s++]=0;
	while(s--)putchar_unlocked(f[s]+'0');
	putchar_unlocked('\n');
}
sum[3<<17],cnt[3<<17];
N,i,acc,t,k,x;
main()
{
	for(;;)
	{
		k=getchar_unlocked();
		if(k<'0'||k>'9')break;
		N=N*10+k-'0';
	}
	for(i=0;i<N;i++)
	{
		x=0;
		for(;;)
		{
			k=getchar_unlocked();
			if(k<'0'||k>'9')break;
			x=x*10+k-'0';
		}
		++sum[cnt[x]++];
	}
	i=0;
	for(t=N;t>0;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)wt(cnt[i]);
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll N,M;
ll dp[305][305][305];
int main(){
  cin>>N>>M;
  vector<vector<pair<ll,ll>>>X(N+1);bool y=true;
  for(int i=0;i<M;i++){
  ll l,r,x;cin>>l>>r>>x;
    if(l==r && x!=1)y=false;
    pair<ll,ll>p(l,x);
    X[r].push_back(p);
  }dp[0][0][0]=1;
  if(!y)
    cout<<0<<endl;
  else{
  for(int i=0;i<N;i++){
  for(int j=0;j<=i;j++)
  for(int k=0;k<=j;k++){
  dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
  dp[i+1][i][k]=(dp[i+1][i][k]+dp[i][j][k])%mod;
  dp[i+1][i][j]=(dp[i+1][i][j]+dp[i][j][k])%mod;
  
  
  }for(auto p:X[i+1]){
  ll l=p.first;
    ll x=p.second;
    if(x==1){
    for(int j=0;j<=i+1;j++)
      for(int k=0;k<=j;k++)
        if(l<=j)dp[i+1][j][k]=0;
    }else if(x==2){
    for(int j=0;j<=i+1;j++)
      for(int k=0;k<=j;k++)
        if(l<=k || j<l)dp[i+1][j][k]=0;
    }else{
     for(int j=0;j<=i+1;j++)
      for(int k=0;k<=j;k++)
        if(k<l)dp[i+1][j][k]=0;
    }
  }
    
    
  }
  ll ans=0;
  for(int j=0;j<=N;j++)
    for(int k=0;k<=j;k++)
      ans=(ans+dp[N][j][k])%mod;
  cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<float> x(N);
  vector<string> u(N);
  float money=0;

  for(int i=0;i<N;i++)  cin>>x[i]>>u[i];

  for(int i=0;i<N;i++){
    if(u[i]=="JPY"){
      money += x[i];
    }
    else if(u[i]=="BTC"){
      money += x[i]*380000.0;
    }
  }

  cout<<money;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
	int a, b, c;
	bool f;
	string s;
	cin >> s;
	LOOP(i,3){
		if(s[i] == s[i+1]){
			cout << "Bad" << endl;return 0;
		}
	}
	cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll res = 1,cnt=0;
    sort(All(A));
    for(int i=N-2;i>=0;i--){
        if(A[i]==A[i+1]){
            res*=A[i];
            cnt++;
            i--;
            if(cnt==2){
                cout << res << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd${0:#:TARGET}

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

    int3(a, b, c);

    if (a == max({a, b, c})) {
        cout << 'A' << endl;
    } else 
    if (b == max({a, b, c})) {
        cout << 'B' << endl;
    } else 
    if (c == max({a, b, c})) {
        cout << 'C' << endl;
    }

    return 0;
}



Measured memory_bytes: 3132
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL gcd(LL a, LL b)
{
	if (a < b) std::swap(a, b);
	LL r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

LL lcm(LL a, LL b)
{
	return a / gcd(a, b) * b;
}

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	std::vector<LL>left(N + 1), right(N + 1);
	rep(i, N)
	{
		if (i == 0)
		{
			left[1] = A[i];
			right[1] = A[N - 1 - i];
		}
		else
		{
			left[i + 1] = gcd(left[i], A[i]);
			right[i + 1] = gcd(right[i], A[N - 1 - i]);
		}
	}

	LL ans = left[N];
	rep(i, N)
	{
		LL res;
		if (i == 0) res = right[N - 1];
		else if (i == N - 1) res = left[N - 1];
		else res = gcd(left[i], right[N - i - 1]);
		ans = std::max(ans, res);
	}
	out << ans << std::endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>	
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int M = 1e9 + 7;
int d[3434][3434], s1[3434][3434], s2[3434][3434];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	char str[5000];
	scanf("%d%s", &n, str + 1);
	s2[0][1] = d[0][1] = 1;
	for(int i = 1; i <= n; ++i){
		s1[0][i] = 1;
	}
	for(int i = 1; i < n; ++i){
		if(str[i] == '<'){
			for(int j = 2; j <= i + 1; ++j){
				d[i][j] = (d[i][j] + s1[i - 1][j - 1]) % M;
			}
		} else {
			for(int j = 1; j <= i; ++j){
				d[i][j] = (d[i][j] + s2[i - 1][j]) % M;
			}
		}
		for(int j = 1; j <= n; ++j){
			s1[i][j] = (s1[i][j - 1] + d[i][j]) % M; 
		}
		for(int j = n; j >= 1; --j){
			s2[i][j] = (s2[i][j + 1] + d[i][j]) % M;
		}
	}	
	/*for(int i = 0; i < n; ++i){
		for(int j = 1; j <= n; ++j){
			printf("%d ", d[i][j]);
		}
		putchar(10);
	}*/
	printf("%d\n", s1[n - 1][n]);
	return 0;
}

Measured memory_bytes: 127232
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
	int h, w, r;
	ll dp[101][8] = { 0 };
	scanf("%d %d %d", &h, &w, &r);
	if (w == 1) {
		printf("%d\n", 1);
		return 0;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < (1 << (w - 1)); j++) {
			if (j & (j >> 1))
				continue;
			int forwarded = 0;
			for (int k = 0; k < (w - 1); k++) {
				if ((j >> k) & 1) {
					dp[i][k] += dp[i - 1][k + 1];
					dp[i][k + 1] += dp[i - 1][k];
					forwarded |= 1 << k;
					forwarded |= 1 << (k + 1);
				}
			}
			for (int k = 0; k < w; k++)
				if (!((forwarded >> k) & 1))
					dp[i][k] += dp[i - 1][k];
			for (int k = 0; k < w; k++)
				dp[i][k] %= 1000000007;
		}
	}
	printf("%d\n", dp[h][r - 1]);
}


Measured memory_bytes: 128