akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	string str;
	cin>>str;
	multiset<char> s;
	forn(i,str.len()){
		s.in(str[i]);
	}
	bool ans = true;
	for(auto c : str){
		if(s.cn(c)!=2)ans=false;
	}
	(ans)?cout<<"Yes\n":cout<<"No\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
    //cin>>t;
    while(t--)
    {
        int n,m,count=0,sum=0,maxi=0,mini=1e18;
        cin>>n>>m;
        cout<<n*m;
        
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
#define MAX_N 100000
typedef long long ll;

int N;
int arr[MAX_N+1];
ll ans = 0;

int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; i++){
		scanf("%d", &arr[i]);
	}
	int cnt = 0;
	for(int i=1; i<=N; i++){
		if(arr[i]==0){
			ans+=(ll)(cnt/2);
			cnt = 0;
		}else if(arr[i]%2==1){
			cnt++;
		}
		ans+=(ll)(arr[i]/2);
	}
	ans+=(ll)cnt/2;
	printf("%lld", ans);
}

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

main(){
  int n,sum1=0,sum2=0;
  cin>>n;
  int ame[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>ame[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int temp=0;
    for(int j=0;j<=i;j++)temp+=ame[0][j];
    for(int j=i;j<n;j++)temp+=ame[1][j];
    ans=max(ans,temp);
  }
  cout<<ans<<"\n";
}


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

int n, k, ans;
int p[1000];

signed main () {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", &p[i]);
	sort(p, p + n);
	for (int i = 0; i < k; ++i)
		ans += p[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 3816
#include <iostream>
#include <math.h>

#define N 1000001

using namespace std;

int main(void){
	bool isprime[N];
	for(int i=0;i<N;i++) isprime[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) isprime[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		if(!n)break;
		int count = 0;
		long long sum = 0;
		for(int i=2;count<n;i++){
			if(isprime[i]){
				sum += i;
				count++;
			}
		}
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int D[310][310][310][2], Mod = 1000000007, n, m;
int main() {
	int i, j, k;
	D[0][1][1][1] = 1;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		for (j = 1; j <= i + 1; j++) {
			for (k = 1; k <= j; k++) {
				int t0 = D[i][j][k][0];
				int t1 = D[i][j][k][1];

				D[i + 1][j][j][1] = (1ll * k*t0 + D[i + 1][j][j][1]) % Mod;
				D[i + 1][j][k][0] = (1ll * (j - k)*t0 + D[i + 1][j][k][0]) % Mod;
				D[i + 1][j + 1][k][0] = (1ll * (n - j)*t0 + D[i + 1][j + 1][k][0]) % Mod;

				if (!t1)continue;
				D[i + 1][j][j][1] = (1ll * j*t1 + D[i + 1][j][j][1]) % Mod;
				D[i + 1][j+1][j][0] = (1ll * (n-j)*t1 + D[i + 1][j+1][j][0]) % Mod;
			}
		}
	}
	printf("%d\n", D[m][n][n][1]);
}

Measured memory_bytes: 221568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<ll,ll>;
ll inf = 1e18;
ll l=1, r=inf;
#define N 100005
vector<P> to[N];
P node[N];
void init(int n) {
    rep(i, n) {
        node[i].first = -1;
        node[i].second = 0;
    }
}
void rec(int v) {
    if(l==inf && r == -inf) return;
    for(P next : to[v]) {
        ll u = next.first;
        ll s = next.second;
        if(node[u].first == -1) {//未到達なら
            node[u].first = s - node[v].first;
            node[u].second = !node[v].second;
            //正・負
            if(!node[u].second) l = max(l, 1-node[u].first);
            else r = min(r, node[u].first-1);
            rec(u);
        } else {
           if(node[v].second != node[u].second) {//異符号
                if(node[v].first+node[u].first != s)
                    l = inf, r = -inf;
            } else if(node[v].second==0 && node[u].second==0) {
                ll tmp = s - node[v].first - node[u].first;
                if(tmp<=0 ||tmp&1) l = inf, r = -inf;
                else if(tmp/2 < l || r < tmp/2) l = inf, r = -inf;
                else l = max(l,tmp/2), r = min(r,tmp/2);
            } else {
                ll tmp = node[v].first + node[u].first - s;
                if(tmp<=0 ||tmp&1) l = inf, r = -inf;
                else if(tmp/2 < l || r < tmp/2) l = inf, r = -inf;
                else l = max(l,tmp/2), r = min(r,tmp/2);
            }
        }
    }
}
int main(void) {
    int n, m; cin >> n >> m;
    init(n);
    rep(i, m) {
        int u, v, s; cin >> u >> v >> s;
        u--; v--;
        to[u].push_back(P{v,s});
        to[v].push_back(P{u,s});
    }
    node[0].first = 0;
    rec(0);
    ll ans = r - l + 1;
    if(ans < 0) ans = 0;
    //printf("%lld %lld ",l,r);
    cout << ans;
}


Measured memory_bytes: 14080
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
A = [[] for _ in range(4)]
for i in range(N):
    w, v = map(int, input().split())
    if i == 0: w0 = w
    A[w-w0].append(v)

B = [[0] for _ in range(4)]
for i in range(4):
    A[i].sort(reverse=True)
    b = 0
    for a in A[i]:
        b += a
        B[i].append(b)
#print(B)
ans = 0
for n1, b1 in enumerate(B[0]):
    for n2, b2 in enumerate(B[1]):
        for n3, b3 in enumerate(B[2]):
            n4 = min((W - n1*w0 - n2*(w0+1) - n3*(w0+2)) // (w0+3), len(B[3])-1)
            if n4 < 0: continue
            ans = max(ans, b1+b2+b3+B[3][n4])

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100;

char s[MAXN + 5][MAXN + 5];
int f[MAXN + 5][MAXN + 5];

int main() {
	int H, W; scanf("%d%d", &H, &W);
	for(int i=1;i<=H;i++)
		scanf("%s", s[i] + 1);
	f[1][1] = (s[1][1] == '#');
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++) {
			if( i == 1 && j == 1 ) continue;
			if( i == 1 ) {
				f[i][j] = f[i][j-1] + (s[i][j] != s[i][j-1]) * (s[i][j] == '#');
			}
			else if( j == 1 )
				f[i][j] = f[i-1][j] + (s[i][j] != s[i-1][j]) * (s[i][j] == '#');
			else f[i][j] = min(f[i-1][j] + (s[i][j] != s[i-1][j]) * (s[i][j] == '#'), f[i][j-1] + (s[i][j] != s[i][j-1]) * (s[i][j] == '#'));
		}
	
	printf("%d\n", f[H][W]);
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for B - Two Colors Card Game
	var N int
	fmt.Scanf("%d", &N)

	answer := make(map[string]int, 100)
	var S string
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S)
		answer[S]++
	}

	var M int
	fmt.Scanf("%d", &M)

	var T string
	for i := 0; i < M; i++ {
		fmt.Scanf("%s", &T)
		answer[T]--
	}

	var max int = 0
	for _, v := range answer {
		if max < v {
			max = v
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N;cin>>N;
	ll ans = 0;
	rep1(i,N+1) {
		if(i%3!=0 and i%5!=0) ans += i;
	}
	cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int p = 2019;
  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
const i64 M = 1000000007;
signed main() {
  const i64 LEN = 80 * 2 * 80 + 1;
  i64 H, W;
  cin >> H >> W;
  vector<vector<i64>> A(H, vector<i64>(W));
  vector<vector<i64>> B(H, vector<i64>(W));
  vector<vector<bitset<LEN>>> D(H, vector<bitset<LEN>>(W));
  REP(i, H) REP(j, W) {
    cin >> A[i][j];
  }
  REP(i, H) REP(j, W) {
    cin >> B[i][j];
  }
  D[0][0].set(abs(A[0][0] - B[0][0]));
  REP(i, H) REP(j, W) {
    i64 c = abs(A[i][j] - B[i][j]);
    if (i > 0) {
      REP(d, LEN) if (D[i - 1][j][d]) {
        D[i][j].set(abs(c - d));
        D[i][j].set(c + d);
      }
    }
    if (j > 0) {
      REP(d, LEN) if (D[i][j - 1][d]) {
        D[i][j].set(abs(c - d));
        D[i][j].set(c + d);
      }
    }
  }
  REP(i, LEN) {
    if (D[H - 1][W - 1][i]) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main() {
    int N;
    cin >> N;
    
    int A[100050];
    HAIRETU(N, A);
    
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            cnt++;
        }
    }
    
    if (N % 2 ==0) {
        if (cnt % 2 == 0) {
            cout << "YES" << endl;
        } else cout << "NO" << endl;
    } else {
        if (cnt % 2 == 0) {
        cout << "NO" << endl;
        } else cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
S = input()
S_list = S.split()

L = int(S_list[0]) + int(S_list[1])
R = int(S_list[2]) + int(S_list[3])
 
if L-R>0:
    print("Left")
elif L-R<0:
    print("Right")
else:
    print("Balanced")

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int a,ans,r,l;
int main() {
	scanf("%d",&r),a=r;
	while(a) l++,a/=10;
	for(int i=1; i<l; i+=2)ans+=pow(10,i)-pow(10,i-1);
	if(l&1)ans+=r-pow(10,l-1)+1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d %d", $k, $s);
$count = 0;
for ($x = 0; $x <= $k; $x++) {
    for ($y = 0; $y <= $k; $y++) {
        $z = $s-$x-$y;
        if ($z>=0 && $z<=$k) $count++;
    }
}
echo $count;

Measured memory_bytes: 4604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCanYouSolveThis solver = new BCanYouSolveThis();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCanYouSolveThis {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int c = in.nextInt();
            int arr[][] = new int[n][m];
            int b[] = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    arr[i][j] = in.nextInt();
                }
            }
            int count = 0;
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = 0; j < m; j++) {
                    sum += arr[i][j] * b[j];
                }
                sum += c;
                if (sum > 0)
                    count++;
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

int main() {
	int n; cin >> n;
	int cnt = 0;
	Loop(i, n) {
		int a; cin >> a;
		if (a % 2 == 1) cnt++;
	}
	if (cnt % 2 == 1) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
static const double pi = 3.141592653589793;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    double a,b,x;cin>>a>>b>>x;
    double l=0;
    double r=90;
    double mid;
    while(r-l>=0.00000001){
        mid=(r+l)/2;
        if(a*tan(mid*pi/180)<=b){
            if((2*b-a*tan(mid*pi/180))*a/2<x/a){
                r=mid;
            }else{
                l=mid;
            }
        }else{
            if((b*b/tan(mid*pi/180))/2<x/a){
                r=mid;
            }else{
                l=mid;
            }
        }
        
    }
    cout<<setprecision(10)<<l<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int a,b,c,dp[100100][4];
string st;
int main(){
	cin>>st;
	dp[0][0]=1;
	for (int i=0;i<st.length();i++){
		if (st[i]=='C'||st[i]=='?'){
			dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mo;
			dp[i+1][1]=(dp[i+1][1]+dp[i][1])%mo;
			dp[i+1][2]=(dp[i+1][2]+dp[i][2])%mo;
			dp[i+1][3]=(dp[i+1][3]+dp[i][3])%mo;
			dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mo;
		}
		if (st[i]=='B'||st[i]=='?'){
			dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mo;
			dp[i+1][1]=(dp[i+1][1]+dp[i][1])%mo;
			dp[i+1][2]=(dp[i+1][2]+dp[i][2])%mo;
			dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mo;
			dp[i+1][3]=(dp[i+1][3]+dp[i][3])%mo;
		}
		if (st[i]=='A'||st[i]=='?'){
			dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mo;
			dp[i+1][1]=(dp[i+1][1]+dp[i][1])%mo;
			dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mo;
			dp[i+1][2]=(dp[i+1][2]+dp[i][2])%mo;
			dp[i+1][3]=(dp[i+1][3]+dp[i][3])%mo;
		}
	}
	cout<<dp[st.length()][3]<<endl;
	return 0;
}


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

void solve() {
    int a, b;
    cin >> a >> b;
    int k;
    cin >> k;
    int g = __gcd(a, b);
    for(int i=g; i>=1; i--) {
        if(g%i == 0)
        {
            if(k == 1) {
                cout << i << "\n";
                return;
            }
            else
                k-=1;
    
        }
    }
    return;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    int tt;
    tt = 1;
    for(int t=1; t<=tt; t++) {
         solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    rep(i, n) {
        scanf("%d", &vec[i]);
    }

    vector<int> even(100010), odd(100010);
    rep(i, n) {
        if(i % 2 == 0) even[vec[i]]++;
        else odd[vec[i]]++;
    }

    int max_even = max_element(even.begin(), even.end()) - even.begin();
    int max_odd = max_element(odd.begin(), odd.end()) - odd.begin();

    int ans = 0;
    if(max_even != max_odd) {
        ans = (n / 2 - even[max_even]) + (n / 2 - odd[max_odd]);
        printf("%d\n", ans);
    }
    else {
        // sort(even.rbegin(), even.rend());
        // sort(odd.rbegin(), odd.rend());
        sort(even.begin(), even.end(), greater<int>());
        sort(odd.begin(), odd.end(), greater<int>());
        ans = min((n / 2 - even[0]) + (n / 2 - odd[1]), (n / 2 - even[1]) + (n / 2 - odd[0]));
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4564
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

vector<vector<pair<int, int>>> v;
int main()
{
  const ll mod = 2019;
  ll l, r; cin >> l >> r;
  ll ans = 1e12;
  r = min(r, l+2019);
  for(ll i = l; i < r; i++){
    for(ll j = l+1; j <= r; j++){
      ll t = 1;
      t *= i; t %= mod;
      t *= j; t %= mod;
      ans = min(ans, t);
    }
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 504
let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int
[for i in 1..n -> abs (((a |> Array.sum) - (a |> Array.take i |> Array.sum)) - (a |> Array.take i |> Array.sum))] |> List.min |> printfn "%d"

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define nodes 400005
#define int long long int
void fast(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
main()
{
    int a;
    cin>>a;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if((i*j)==a){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
    
 
}


Measured memory_bytes: 256
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        r: i64,
    }

    println!("{}", 3 * r * r);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inputN = sc.next();
		String inputK = sc.next();

		int argN = Integer.parseInt(inputN);
		int argK = Integer.parseInt(inputK);

		if(argK*2-1 <= argN) {
			System.out.println("YES");
			sc.close();
		}else {
			System.out.println("NO");
			sc.close();
		}
	}
}

Measured memory_bytes: 21844
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var abc=[[],[],[]];
var obj={};
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   abc[Math.floor(i/8)].push(arr[1]);
   obj[arr[1]]=arr[0];
}
for(var i=0;i<3;i++)abc[i].sort(function(a,b){return a-b;});
console.log(obj[abc[0][0]]+" "+(abc[0][0].toFixed(2)));
console.log(obj[abc[0][1]]+" "+(abc[0][1].toFixed(2)));
console.log(obj[abc[1][0]]+" "+(abc[1][0].toFixed(2)));
console.log(obj[abc[1][1]]+" "+(abc[1][1].toFixed(2)));
console.log(obj[abc[2][0]]+" "+(abc[2][0].toFixed(2)));
console.log(obj[abc[2][1]]+" "+(abc[2][1].toFixed(2)));
var d=[];
for(var i=0;i<3;i++)d.push(abc[i][2]);
d.sort(function(a,b){return a-b;});
console.log(obj[d[0]]+" "+(d[0].toFixed(2)));
console.log(obj[d[1]]+" "+(d[1].toFixed(2)));

Measured memory_bytes: 7908
#include<stdio.h>

long lucas(long a,long b,int n){
  if(n<2){
    return a+b;
  }else{
    lucas(a+b,a,--n);
  }
}

int main(){

int N;
scanf("%d",&N);

if (N==1){ 
  puts("1");
}else{
  printf("%ld",lucas(1,2,N-1));
}

return 0;

}

Measured memory_bytes: 1732
#include <string>
#include <iostream>

using namespace std;

string S;

int main()
{
	cin >> S;

	int ret = (S.size() % 2 != 0 && S[S.size() / 2] != 'i' && S[S.size() / 2] != 'w' ? 1 : 0);

	for (int i = 0; i < S.size() / 2; i++)
	{
		char l = S[i];
		char r = S[S.size() - i - 1];

		bool flag = true;

		if (l == 'i' && r == 'i') flag = false;
		if (l == 'w' && r == 'w') flag = false;
		if (l == '(' && r == ')') flag = false;
		if (l == ')' && r == '(') flag = false;

		if (flag) ret++;
	}
	
	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	double n,ans=0;
 	cin >> n;
 	for (int i = 0; i < n; i++){
 		if((i+1)%2==1){
 			ans++;
 		}
 	}
 	
 	double a=ans/n;
 	cout << a << endl;
 }

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

using namespace std;

int main(){
  long n,k;
  cin >> n;
  cin >> k;
  long d;
  long num;
  
  vector<long> a;
  for(int i=0;i<n;i++){
    a.push_back(0);
  }
  for(int i=0;i<k;i++){
    cin >> d;
    for(int j=0;j<d;j++){
      cin >> num;

      a[num-1] = 1;
    
    }
  }
  long c=0;

  for(int i=0;i<n;i++){
    if(a[i]==1){
      c++;
    }
    
  }

  cout << n-c;


}

Measured memory_bytes: 3192
d, g = map(int, input().split(' '))
g = g//100
df = [list(map(int, input().split(' '))) for _ in range(d)]

df = [[df[i][0], i+1, (df[i][1]//100)+(i+1)*df[i][0]] for i in range(d)]
result = 10**9
for i in range(2**d):
    counter = [0, 0, [0]]
    bin_i = format(i, 'b').zfill(d)
    for j in range(1, len(bin_i)+1):
        if bin_i[-j] == '1':
            counter[0] += df[j-1][0]
            counter[1] += df[j-1][2]
        else:
            counter[2].append(j)
    if counter[1] < g:
        j = max(counter[2])
        if g - counter[1] <= df[j-1][0]*j:
            counter[0] -= ((-1)*(g - counter[1]))//j
        else:
            counter[0] = 10**9
    result = min(counter[0], result)
print(result)

Measured memory_bytes: 3188
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int h, w;
	cin >> h >> w;
	vector<string> ss(h);
	for(int i = 0; i < h; ++i){
		cin >> ss[i];
	}
	VV(char) vis;
	initvv(vis, h, w);

	auto in = [=](int y, int x){
		return y >= 0 && y < h && x >= 0 && x < w;
	};
	
	const int dd[] = {0, 1, 0, -1, 0};

	LL ans = 0;
	queue<int> q;
	for(int sy = 0; sy < h; ++sy)
	for(int sx = 0; sx < w; ++sx){
		if(!vis[sy][sx] && ss[sy][sx] == '#'){
			q.push(sy << 16 | sx);
			LL cnt[2] = {};
			vis[sy][sx] = 1;
			while(!q.empty()){
				int y = q.front() >> 16, x = q.front() & 0xffff;
				q.pop();
				++cnt[ss[y][x] == '.'];
				for(int i = 0; i < 4; ++i){
					int ny = y + dd[i], nx = x + dd[i + 1];
					if(in(ny, nx) && !vis[ny][nx] && ss[ny][nx] != ss[y][x]){
						q.push(ny << 16 | nx);
						vis[ny][nx] = 1;
					}
				}
			}
			ans += cnt[0] * cnt[1];
		}
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

int a[200009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, x; cin >> n >> x;
	if (x == 1 || x == n * 2 - 1) {
		cout << "No" << '\n';
		return 0;
	}
	cout << "Yes" << '\n';
	for (int i = 0; i < n * 2 - 1; i++)
		a[(n + i) % (n * 2 - 1)] = (x + i) % (n * 2 - 1);
	for (int i = 0; i < n * 2 - 1; i++)
		cout << a[i] + 1 << '\n';
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,A,B;
vector<ll> V;
void input(){
    fast_io();
    cin >> N >> A >> B;
    V = fetch_vec<ll>(N);
    sort(V.begin(),V.end(),greater<ll>());
}

ll C(int n, int k){
    ll ans = 1LL;
    if(n<k) return 0;
    for (int i = 0; i < k; i++)
    {
        ans *= (n-i);
        ans /= (i+1);
    }
    // for (int i = 0; i < k; i++)
    // {
    // }
    return ans;
}

int solve(){
    // 平均値の最大化は単純に、ソートして大きい順にA個とればいい。
    double ans = accumulate(V.begin(),V.begin()+A,0.00);
    ans /= A;
    cout << fixed << setprecision(6) << ans << endl;
    map<ll,ll> cnt_all,cnt_av;
    for (int i = 0; i < N; i++)
    {
        cnt_all[V[i]]++;
        if(i<A) cnt_av[V[i]]++;
    }
    // ll fact[60];
    // fact[0] = 1;
    // for (int i = 0; i < 50; i++)
    // {
    //     fact[i+1] = (i+1)*fact[i];
    // }
    ll M = cnt_all[V[A-1]];
    ll K = cnt_av[V[A-1]];
    if(K<A){
        // ll cnt = fact[M]/fact[K]/fact[M-K];
        ll cnt = C(M,K);
        cout << cnt << endl;
    }
    else
    {
        K = min(cnt_all[V[A-1]],B);
        ll cnt = 0;
        DBG(M)
        DBG(K)
        for (int k = A; k <= K; k++)
        {
            // cnt += fact[M]/fact[k]/fact[M-k];
            cnt += C(M,k);
            DBG(cnt)
        }
        cout << cnt << endl;
    }
    
    
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  vi a(N);
  int asum = 0;
  int mn = 1e15;
  int mnp, cnt = 0;
  bool a0 = false;
  rep(i,N){
    cin >> a[i];
    if(a[i] == 0){a0 = true; continue;}
    if( a[i] < 0) cnt++;
    asum += abs(a[i]);
    if(abs(a[i])<mn){
      mn = abs(a[i]);
      mnp = i;
    }
  }
  if(a0 || cnt%2 == 0) cout << asum << endl;
  else cout << asum - mn*2 << endl;
  return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#define N 100

using namespace std;

int main() {
	ios::sync_with_stdio(false);

	int A[N], n, cnt = 0;

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

	for(int i = 0; i < n; ++i) {
		int mini = i;
		for(int j = i; j < n; ++j) {
			if(A[j] < A[mini]) {
				mini = j;
			}
		}
		if(mini != i) {
			int tmp = A[i];
			A[i] = A[mini];
			A[mini] = tmp;

			++cnt;
		}
	}

	for(int i = 0; i < n; ++i) {
		if(i != 0) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;
	return 0;
}

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


ll a[300000], l[200001], r[200001];

int main() {
  int n, n2, n3;
  scanf("%d", &n);
  n2 = 2*n;
  n3 = 3*n;
  for (int i = 0; i < n3; ++i) scanf("%lld", a+i);

  ll sum = 0;

  {
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0; i < n; ++i) {
      sum += a[i];
      pq.push(a[i]);
    }

    l[n-1] = sum;
    for (int i = n; i < n2; ++i) {
      pq.push(a[i]);
      sum += a[i] - pq.top();
      pq.pop();
      l[i] = sum;
    }
  }
  
  {
    priority_queue<int> pq;
    sum = 0;
    for (int i = n3-1; i >= n2; --i) {
      sum += a[i];
      pq.push(a[i]);
    }

    r[n2] = sum;
    for (int i = n2-1; i >= n; --i) {
      pq.push(a[i]);
      sum += a[i] - pq.top();
      pq.pop();
      r[i] = sum;
    }
  }

  ll ans = -(1ll<<62);
  for (int i = n; i <= n2; ++i) {
    ll tmp = l[i-1] - r[i];
    if (tmp > ans) ans = tmp;
  } 
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 5364
#include <iostream>
#include <cstdio>
using namespace std;
int a[5];
int main() {
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3548
use proconio::input;
use std::cmp::*;

fn gcd(n: usize,m: usize) -> usize{
    assert!(n > m);
    if m == 0{
        return n
    }
    gcd(m,n % m)
}

fn lcm(n: usize,m: usize) -> usize{
    assert!(n > m);
    n / gcd(n,m) * m
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let (N,M) = {
        if n < m{
            (m,n)
        }else{
        (n,m)
        }
    };
    let res = lcm(N,M);
    println!("{}",res);
}


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

using namespace std;

int main() {
    unsigned int n;
    cin >> n;

    vector<long long> a(n);
    vector<long long> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        
        if (i % 2 == 0) {
            x[0] += a[i];
        } else {
            x[0] -= a[i];
        }
    }

    for (int i = 0; i + 1 < n; ++i) {
        x[i + 1] = 2 * a[i] - x[i];
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i];
        (i != n - 1) ? (cout << " ") : (cout << endl);
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
#define  sf  scanf
#define  pf  printf
ll a[10005];
int main()
{
    ll s,j,z,i,n,m;
    sf("%lld",&n);
    for(i=0; i<n; i++)
    {
        sf("%lld",&a[i]);
    }
    s=0;
    for(i=0; i<n; i++)
    {
        if(a[i]%2==0)
        {
            while(a[i]%2==0)
            {
                a[i]/=2;
                s++;
            }
        }
    }
    pf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++)c[i][0] = 0;
	for (int j = 0; j <= n; j++)c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}

	return maxl;
}

int main() {
	string s1, s2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}

	return 0;
}


Measured memory_bytes: 7104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
void solve()
{
   string s,t;
   cin>>s>>t;
   cout<<t+s<<endl;

}

int main()
{

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }



}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int rn = uniform_int_distribution<int>(0, MAXN)(rng);

    ll n;
    cin>>n;

    int k = 0;

    FOR(i,2,n) {
        ll p = i;
        p = p*(p-1);
        if(p == n*2) {
            k = i;
            break;
        }
    }
    //cout<<k<<endl;
    
    if(n == 1) {
        cout<<"Yes"<<endl<<"2"<<endl;
        cout<<"1 1"<<endl;
        cout<<"1 1"<<endl;
    }
    else if(k == 0) cout<<"No";
    else {
        vi v[k];
        int p = 1, index = 0;
        while(index < k-1) {
            int z = k - 1 - index;
            REP(i,z) v[index].PB(p), p++;
            FOR(i,index,k-2) v[i+1].PB(v[index][i]);
            index++;
        }
        cout<<"Yes"<<endl;
        cout<<k<<endl;
        REP(i,k) {
            cout<<v[i].size()<<" ";
            REP(j,v[i].size()) cout<<v[i][j]<<" "; cout<<endl;
        }
    }
	return 0;
}






Measured memory_bytes: 2304
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,ll> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int main(){
    int A,B;
    cin>>A>>B;
    int ans=A-B*2;
    if(ans<0) ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
const double EPS = 1e-8;

double sqrt_user(double x) {
    double lb = 0, ub = 10000;
    for(int i=0; i<200; i++) {
        double mid = (lb + ub) / 2.0;
        if(mid * mid < x) lb = mid;
        else ub = mid;
    }
    return lb;
}

int ans[3];
void put(double x) {
    if(abs(x) < EPS) ans[1]++;
    else if(x < -EPS) ans[2]++;
    else ans[0]++;
}

double f(double a, double b, double c, double d, double x) {
    return a*x*x*x + b*x*x + c*x + d;
}

double solve(double a, double b, double c, double d) {
    if(a == 0) {
        // printf("D = %.12f\n", c*c - 4*b*d);
        if(c*c - 4*b*d < -EPS) return 0;

        double vl = (-c + sqrt_user(c*c - 4*b*d)) / (2 * b);
        double vr = (-c - sqrt_user(c*c - 4*b*d)) / (2 * b);

        // printf("vl = %.12f, vr = %.12f\n", vl, vr);
        put(vl);
        put(vr);

        return 0;
    }
    else {
        if(a < 0) {
            a = -a, b = -b, c = -c, d = -d;
        }

        double lb = -10000, ub = 10000;
        for(int i=0; i<300; i++) {
            double mid = (lb + ub) / 2.0;
            if(f(a, b, c, d, mid) > 0) ub = mid;
            else lb = mid;
        }

        put(lb);
        return lb;
    }
}
 
signed main() {
    int T; cin >> T;
    while(T--) {
        memset(ans, 0, sizeof(ans));
        int a, b, c, d; cin >> a >> b >> c >> d;

        double n = solve(a, b, c, d);
        // printf("n = %.12f\n", n);
        solve(0, a, n*a+b, n*(n*a+b)+c);

        cout << ans[0] << " " << ans[2] << endl;
    }
    return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

//typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

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

    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    s += '0';

    repr(i, 1, s.size()) if(s[i] != s[i-1]) ++ans;
    cout << ans << endl;

    return 0;
} 

Measured memory_bytes: 512
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int N=100,M=100000;
int n,m;
int a[N+1];
bool sg[M+1];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			sg[i]|=i>=a[j]&&!sg[i-a[j]];
	puts(sg[m]?"First":"Second");
	return 0;
}
/*1
2 4
2 3
*/
/*2
2 5
2 3
*/
/*3
2 7
2 3
*/
/*4
3 20
1 2 3
*/
/*5
3 21
1 2 3
*/
/*6
1 100000
1
*/

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

int main() {
  int N, K, sum, x; 
  cin >> N >> K;
  sum = 0;
    
  for (int i = 0; i < N; i++ ){
  cin >> x ;
    
    if ( x <= K - x ){
     sum += x;
    }
    else{
     sum += (K - x) ;
    }
  }
  cout << sum * 2 << endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	ans := 1
	min := p[0]
	for i := 1; i < n; i++ {
		pi := p[i]
		if pi <= min {
			ans++
		}
		if pi < min {
			min = pi
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6144
import copy
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
y = copy.deepcopy(x)
cnt = 0
inside = 0
for nx, i in enumerate(x[:]):
  # print(i)
  for ny, j in enumerate(y[:]):
    # print(j)
    inside = 0
    if nx != ny:
      for item in range(d):
        inside += (i[item] - j[item]) ** 2
        # print('inside = %d' % inside)
      root = math.sqrt(inside)
      if root.is_integer():
        cnt += 1
print(int(cnt / 2))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

int digit(long long int n){
    string s;
    s = std::to_string(n);
    return s.size();
}

int main(){
    ll N; cin>> N;
    vll m = divisor(N);
    ll ans = 10000;
    for(auto x: m){
        ll y = N/x;
        ll p = max(digit(x), digit(y));
        if(p < ans){ans = p;}
    }
    cout << ans;
}

Measured memory_bytes: 256
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    while(true) {
      val in = StdIn.readLine().split(" ").map(_.toInt)
      val H = in(0)
      val W = in(1)
      if(H == 0 && W == 0) return
      for(i <- 1 to H;j <- 1 to W){
        print(
          (i,j) match {
          case (1,_) | (_,1) | (H,_) | (_,W)=> "#"
          case _ => "."
          }
        )
        if(j == W){println()}
      }
      println()
    }
  }
}

Measured memory_bytes: 54644