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

using namespace std;
int main()
{
    int x,i;
    string a,b;
    int count=0;

 cin>>a;
 cin.ignore(numeric_limits<streamsize>::max(), '\n');
 cin>>b;
  x=b.size();

 for( i=0;i<x;i++)
  {

   if(a[i]!=b[i])
    {
      count++;
    }
  }
  cout<<count;

}

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		int sum = 0;
		for (int i = 2; i < 46; i++){
			if (i % 2 == 0) {
				if (n % i == i / 2) {
					if (n >= i*i / 2)sum++;
				}
			}
			else {
				if (n % i == 0) {
					if (n >= i*(i + 1) / 2)sum++;
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k; 
	int p=1;
	for(int i=1;i<=n;i++){
		if(k>p)p*=2;
		else p+=k;
	}
	cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int ans = 0;
    
    while(N>0){
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            A[i] /= 2;
        }else{
            cout << ans << endl;
            return 0;
        }
    }
        ans++;
    }
        return 0;
}




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

int main(){

  int n,z=0;
  cin>>n;
  int a[2*n];

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

  for(int i=0;i<2*n-4;i=i+2){

  if(a[i]==a[i+1]){

  if(a[i+2]==a[i+3] && a[i+4]==a[i+5]){

  cout<<"Yes"<<endl;
    z++;
    break;

  }

  }
  }

  if(z==0) cout<<"No"<<endl;












}


Measured memory_bytes: 3636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

constexpr long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N;
	vector<long long int>a(N / 2 + 1);
	vector<long long int>by(N + 1, 1);
	vector<long long int>rev(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	for (int i = 0; i <= N / 2; i++) {
		a[i] = by[N / 2] * rev[N / 2 - i];
		a[i] %= MOD;
		a[i] *= rev[i];
		a[i] %= MOD;
		a[i] *= power(2, N / 2 - i, MOD);
		a[i] %= MOD;
	}
	auto asum = a;
	for (int i = 1; i <= N / 2; i++) {
		asum[i] += asum[i - 1];
		asum[i] %= MOD;
	}
	long long int ans = power(3, N, MOD);
	long long int minus = 0;
	for (int i = 1; i <= N / 2; i++) {
		long long int box = asum[N / 2] - asum[N / 2 - i];
		box += MOD;
		box %= MOD;
		box *= a[i];
		box *= 2;
		box %= MOD;
		minus += box;
		minus %= MOD;
	}
	ans -= minus;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int bh = 0;
  for (int i = 1; i <= (b - a); i++) {
    bh += i;
  }
  cout << bh - b << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split())
KS = [[int(x) for x in input().split()] for _ in range(M)]
P = list(map(int, input().split()))

bit = (1 << N)
cnt = 0

#print(bit)

for i in range(bit):
    switch = [0] * (N+1)
    for j in range(N):
        isOn = (i >> j) & 1
        switch[j + 1] = isOn

    #print(switch[1:])

    ok = True
    for k in range(M):
        t = KS[k][1:]
        c = 0
        for l in t:
            c += switch[l]

        #print(k, c, P[k])

        if c % 2 != P[k]:
            ok = False
            break

    if ok:
        cnt += 1

print(cnt)


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

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

    long a,b;
    while(cin >> a >> b){
        cout.precision(5);
        cout << a / b << " " << a % b <<  " "  << fixed << (double)a / (double)b << endl;
        return 0;
    }
}

Measured memory_bytes: 3284
#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 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; }
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);

	int n;
	cin >> n;
	if(n<=999) cout << "ABC" << endl;
	else cout << "ABD" << endl;

}


Measured memory_bytes: 256
import collections

N = int(input())
G = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    u,k,*varray = map(int,input().split())
    for v in varray:
        G[u-1][v-1] = 1
        
D = [-1 for _ in range(N)]
D[0] = 0
Q = collections.deque()
Q.append(0)
while len(Q) > 0:
    # print("bfs",Q)
    cur = Q.popleft()
    for dst in range(N):
        if G[cur][dst] == 1 and D[dst] == -1:
            D[dst] = D[cur] + 1
            Q.append(dst)
for v in range(N):
    print(v+1, D[v])
            

# 順番を書こう。落ち着け
# まずd=1の時→行列の一行目をみよう
# 1になっている列を探す→そいつらのDは全部2に変える
# プラスしてそいつらのしもべたちを3にする
# 


Measured memory_bytes: 6092
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n, m;

    cin >> n >> m;

    vector<int> a(n);

    int sum = 0;

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

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] *4.0 * m >= sum)
        {
            ans++;
        }
    }

    if (m <= ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int ans=m;
    for(int i=0;i<=n-m;i++){
    	int c=m;
    	for(int j=0;j<m;j++){
    		if(t[j]==s[j+i])c--;
		}
    	ans=min(ans,c);
	}
	if(m==0)cout<<"0";
	else cout<<ans;
return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;

int main() {
    ll a,b;
    cin >> a >> b;
    string x[10001];
    for (ll i=0;i<a;++i){
        cin >> x[i];
    }
    sort(x,x+a);
    for (ll i=0;i<a;++i){
        cout << x[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
typedef long long int ll;

int nextsmallest(vector<int> &v, int sidx) {
    int l = 0, u = v.size()-1;
    if (v[0] > sidx) {
        u = 0;
    } else if (v[u] > sidx) {
        while (u - l > 1) {
            int b = (l+u+1)/2;
            ll h = v[b];
            if (h > sidx) u = b;
            else if (h < sidx) l = b;
            else u = l = b+1;
        }
    } else u = u + 1;
    
    u = u%v.size();
    return u;
}

int main(int argc, const char * argv[]) {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    if (H == 1) B = A;
    if (W == 1) A = B;
    REP(i, H) {
        REP(j, W) {
            if ((i < B && j < A) || (i>=B && j >= A)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
n,m,x=map(int,input().split())
c=[]
a=[]
result=-1
for _ in range(n):
  t=list(map(int,input().split()))
  c.append(t[0])
  a.append(t[1:])

for i in range(2**n):
  money=0
  tm=[0]*m
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j]
    for k in range(m):
      tm[k]+=a[j][k]
    if all(xx>=x for xx in tm):
      if result==-1:
        result=money
      else:
        result=min(money,result)
print(result)

Measured memory_bytes: 9252
def f(b,n):
  if n<b:return n
  return f(b,n//b)+n%b

n=int(input())
s=int(input())

if n==s:
  print(n+1)
  exit()
for b in range(2,int(n**0.5)+1):
  if f(b,n)==s:
    print(b)
    break
else:
  for p in range(1,int(n**0.5)+1)[::-1]:
    b,m=divmod(n-s+p,p)
    if m==0 and b>=2 and f(b,n)==s:
      print(b)
      break
  else:
    print(-1)

Measured memory_bytes: 3188
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


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

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n;
    cin>>n;
    n %= 10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout<<"hon";
    }else if(n==0||n==1||n==6||n==8){
        cout<<"pon";
    }else{
        cout<<"bon";
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    REP(i,0,a){
        if(s[i]<'0' || s[i]>'9') ans =false;
    }
    if(s[a]!='-') ans=false;
    for(int i=a+1; i<a+b+1; ++i){
        if(s[i]<'0' || s[i]>'9') ans =false;
    }
    //処理
    
    //出力
    if(ans) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	string s,t;
	int a, b;
	string u;
	cin>>s>>t>>a>>b>>u;
	if(u==s){
		cout<<a-1<<" "<<b;
	}
	else {
		cout<<a<<" "<<b-1;
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll r;
  cin>>r;
  
  ld ans=M_PI*r*2.0;
  cout<<Decimal;
  cout<<ans<<endl;
}



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

int main() {
 int a,b,c;
  cin>>c>>a>>b;
  if(a<=b){
  	if(a+c <b){
    	cout<<b-a-c<<endl;
    }
    else
      cout<<0<<endl;
  }
  else{
  	if(b+c<a){
    	cout<<a-b-c<<endl;
    }
    else
      cout<<0<<endl;
  }
  
  
  
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>

using namespace std;

int main()
{
  int X, A;
  cin >> X >> A;

  if (X < A) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int a,p;
	int r;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&a,&p);
//	scanf_s("%d %d",&a,&p);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=0;i<n;i++){
//		scanf("%d",&a[i]);
		scanf_s("%d",&a[i]);
	}

	for(i=0;i<m;i++){
//		scanf("%d %d",&card[i].kosu,&card[i].num);
		scanf_s("%d %d",&card[i].kosu,&card[i].num);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	ans=(a*3+p)/2;

	

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, h, cnt = 0;
	cin >> n >> k;
	while (n--) {
		cin >> h;
		if (h >= k)
			++cnt;
	}
	cout << cnt << '\n';
	return 0;
}

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


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int ii=a; ii<=b; ii++){
        if(c%ii==0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long

int n,x,c[201000];
vector<int>a;

int32_t main()
{	
	cin >> n;
	memset(c, 0, n+1);
	for(int i=0; i<n; i++)
	{	
		cin >> x;
		a.push_back(x);
		c[x]++;
	}
	
	int r = 0, comb[201000];
	memset(comb, 0, n+1);
	
	for(int i=0; i<n; i++)
		if (comb[a[i]] == 0)
		{
			comb[a[i]] = c[a[i]]*(c[a[i]]-1)/2;
			r += comb[a[i]];
		}
	
	//cout << r << '\n';
	for(int i=0; i<n; i++)
	{
		int ans = r - (c[a[i]] - 1);
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 6384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[][] a = new int[n*2][3];
        for (int i = 0; i < n; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            int x = sc.nextInt();
            a[i+n][0] = s - x;
            a[i+n][1] = 1;
            a[i+n][2] = x;
            a[i][0] = t - x;
            a[i][1] = -1;
            a[i][2] = x;
        }
        Arrays.sort(a, (x, y) -> x[0] - y[0]);
        int[] d = new int[q];
        for (int i = 0; i < q; i++) {
            d[i] = sc.nextInt();
        }
        int[] ans = new int[q];
        Arrays.fill(ans, -1);
        TreeSet<Integer> set = new TreeSet<>();
        int idx = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n*2; i++) {
            while(idx < q && d[idx] < a[i][0]){
                if(set.isEmpty()) ans[idx] = -1;
                else ans[idx] = set.first();
                idx++;
            }
            if(idx == q) break;
            if(a[i][1] == 1){
                set.add(a[i][2]);
            }else{
                set.remove(a[i][2]);
            }
        }
        for (int i = 0; i < q; i++) {
            sb.append(ans[i]).append("\n");
        }
        System.out.println(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 194896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

ll memo[52][52][2505];
void init (){
    for (int yi = 0; yi < 52; ++yi) {
        for (int xi = 0; xi < 52; ++xi) {
            for (int zi = 0; zi < 2505; ++zi) {
                memo[yi][xi][zi] = 0;
            }
        }
    }
}

int main() {
    int N,A;
    cin >> N >> A;
    int x[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }
    memo[0][0][0] = 1;
    memo[0][1][x[0]] = 1;
    for (int ni = 1; ni < N; ++ni) {
        for(int ci = 0; ci < 51; ci++){
            for(int xi = 0; xi < 2505; xi++){
                memo[ni][ci][xi] += memo[ni - 1][ci][xi];
                memo[ni][ci + 1][xi + x[ni]] += memo[ni - 1][ci][xi];
            }
        }
    }
    ll sum = 0;
    for(int ci = 1; ci <= N; ci++){
        for(int xi = 0; xi <= 2505; xi++){
            if(ci * A == xi){
                sum += memo[N-1][ci][xi];
            }
        }
    }
    cout << sum << endl;
}


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

using namespace std;
using ll = long long;

int main(){
    string n;
    cin>>n;
    reverse(n.rbegin(),n.rend());
    int ans=0;
    for (int i = 0; i < n.size(); ++i) {
        ans+=(int)(n[i]-'0');
    }
    for (int i = 0; i < n.size(); ++i) {
        if(i+1!=n.size()){
            if(n[i]=='5'){
                if(n[i+1]<'5')continue;
            }
            else if(n[i]<'5')continue;
        }
        else{
            if(n[i]<='5')continue;
        }

        ans+=(int)('9'-n[i])+1;
        ans-=(int)(n[i]-'0');
        ++ans;
        n[i]='0';
        while(i+1<n.size()&&n[i+1]=='9'){
            ans-=9;
            n[i+1]='0';
            ++i;
        }
        ++n[i+1];
    }
    cout<<ans<<endl;
    return 0;
}

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

bool dp[17][1<<16];
int main(){
  int n,h[16],w[16];
  char r[3]={'R','G','B'};
  string c[4];
  cin>>n;
  for(int i=0;i<n;i++)cin>>h[i]>>w[i];
  for(int i=0;i<4;i++)cin>>c[i];

  int a1[16][7][7],o1[16][3][7][7]={};
  for(int i=0;i<n;i++)
    for(int j=0;j<7;j++)for(int k=0;k<7;k++)a1[i][j][k]=(1<<16)-1;
  
  for(int k=0;k<n;k++)
    for(int cl=0;cl<3;cl++)
      for(int y=-h[k]+1;y<4;y++)
	for(int x=-w[k]+1;x<4;x++){
	  for(int l=max(0,y);l<min(4,y+h[k]);l++)
	    for(int m=max(0,x);m<min(4,x+w[k]);m++){
	      int xx=l*4+m;
	      if(c[l][m]==r[cl])o1[k][cl][y+3][x+3]|=1<<xx;
	      if(!cl)a1[k][y+3][x+3]-=1<<xx;
	    }
	}
  
  dp[0][0]=1;
  for(int j=0;j<16;j++)
    for(int i=0;i<1<<16;i++)
      if(dp[j][i])
	for(int k=0;k<n;k++)
	  for(int cl=0;cl<3;cl++)
	    for(int y=-h[k]+1;y<4;y++)
	      for(int x=-w[k]+1;x<4;x++){
		int ni=(i&a1[k][y+3][x+3])|o1[k][cl][y+3][x+3];
		dp[j+1][ni]=1;
		if(ni==(1<<16)-1){cout<<j+1<<endl;return 0;}
	      }
}

Measured memory_bytes: 4108
#include <stdio.h>
int main(void) {
    long long n,a,min=1000000,max=-1000000,m=0;
    scanf("%lld", &n);
    for (long long i = 0; i <= n-1; i++) {
        scanf("%lld", &a);
        if (a > max)max = a;
        if (a < min)min = a;
        m += a;
    }
    printf("%lld %lld %lld\n", min, max,m);
    
    return 0;
}


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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数
//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}
//to_char
char to_char(int i){
  if (i == 0) {
    return '0';
  }
  if (i == 1) {
    return '1';
  } 
  if (i == 2) {
    return '2';
  } 
  if (i == 3) {
    return '3';
  }
  if (i == 4) {
    return '4';
  } 
  if (i == 5) {
    return '5';
  } 
  if (i == 6) {
    return '6';
  }
  if (i == 7) {
    return '7';
  } 
  if (i == 8) {
    return '8';
  } 
  if (i == 9) {
    return '9';
  }
  return ' ';  
}
//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, M;
  cin >> N >> M;
  priority_queue<ll> A;
  for (int i = 0; i < N; i++) {
    int P;
    cin >> P;
    A.push(P);
  }
  for (int i = 0; i < M; i++) {
    A.push(A.top() / 2);
    A.pop();
  }
  ll ans = 0;
  while (!A.empty()) {
    ans += A.top();
    A.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 4328
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) cout << "Yes" << endl;
  else if (abs(a - b) <= d and abs(b - c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

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

    lld lim = sqrt(N);
    lld ans = LLONG_MAX;
    for(lld i = 1; i <= lim; i++) {
        if(N % i == 0) {
            lld x = i;
            lld y = N / i;
            ans = min(ans, x + y - 2);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#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 n;cin>>n;
    int ans=0;
    vector<int> arr;
    int a;
    for (int i=0;i<n;i++){
        cin>>a;
        arr.emplace_back(a);
    }
    sort(arr.begin(),arr.end());
    for (int i=0;i<arr.size();i++){
        if (arr[i]%10==0){
            ans+=arr[i];
            arr.erase(arr.begin()+i);
            i--;
        }
    }if (arr.size()>=1){
        for (int i=0;i<arr.size();i++){
            ans+=arr[i];
        }if (ans%10==0){
            ans-=arr[0];
        }
    }if (ans%10==0){
        cout<<0;
    }else cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#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<int, int>;

struct Point {
  double x, y;
};

void koch(int n, Point a, Point b) {
  if (n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

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

  Point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    int result = 0;
    while (n > 0) {
        if ((n%10 != 9) && n>9) {
            result += 9;
            n = (n/10) - 1;
        } else {
            result += n%10;
            n /= 10;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

struct modint{
	int v = 0;
	int operator=(const int& rhs){
		v = rhs;
		return v;
	}
	bool operator==(const modint& rhs){
		return (v == rhs.v);
	}
	modint operator+(const modint &rhs){
		modint ret;
		ret.v = v + rhs.v;
		ret.v = (ret.v<MOD)?ret.v:(ret.v-MOD);
		return ret;
	}
	void operator+=(const modint &rhs){
		v += rhs.v;
		v = (v<MOD)?v:(v-MOD);
	}
	modint operator-(const modint &rhs){
		modint ret;
		ret.v = v - rhs.v;
		ret.v = (ret.v<0)?(ret.v+MOD):ret.v;
		ret.v = (ret.v<MOD)?ret.v:(ret.v-MOD);
		return ret;
	}
	void operator-=(const int &rhs){
		v -= rhs;
		v = (v<0)?v+MOD:v;
		v = (v<MOD)?v:(v-MOD);
	}
	void operator-=(const modint &rhs){
		v -= rhs.v;
		v = (v<0)?v+MOD:v;
		v = (v<MOD)?v:(v-MOD);
	}
	modint operator*(const modint &rhs){
		ll tmp = 1ll;
		modint ret;
		tmp *= v;
		tmp *= rhs.v;
		tmp %= MOD;
		ret.v = tmp;
		return ret;
	}
	void operator*=(const modint &rhs){
		ll tmp = 1ll;
		tmp *= v;
		tmp *= rhs.v;
		tmp %= MOD;
		v = tmp;
	}
	modint operator/(const modint &rhs){
		modint ret;
		ll t=1ll,a,p = MOD-2;
		a = rhs.v;
		while(p){
			if(p%2){
				t *= a;
				t %= MOD;
			}
			a *= a;
			a %= MOD;
			p /= 2;
		}
		t *= v;
		t %= MOD;
		ret.v = t;
		return ret;
	}
	void operator/=(const modint &rhs){
		ll t=1ll,a,p = MOD-2;
		a = rhs.v;
		while(p){
			if(p%2){
				t *= a;
				t %= MOD;
			}
			a *= a;
			a %= MOD;
			p /= 2;
		}
		t *= v;
		t %= MOD;
		v = t;
	}
	bool operator<(const modint &rhs){
		return (v<rhs.v);
	}
	bool operator<=(const modint &rhs){
		return (v<=rhs.v);
	}
	void operator ++() {
		v += 1;
		v = (v<MOD)?v:(v-MOD);
	}
};

ostream& operator <<(ostream& o, const modint &rhs){
	o << rhs.v;
	return o;
}

istream& operator >>(istream& o, modint& rhs){
	o >> rhs.v;
	return o;
}

int main(void){
	modint i,n,m,k,ans,t;
	cin >> n >> m >> k;
	t = n*m;
	for(i=1; i<n; ++i){
		ans += (i)*(n-i)*m*m;
	}
	for(i=1; i<m; ++i){
		ans += (i)*(m-i)*n*n;
	}
	k -= 2; t -= 1;
	for(i=1; i<=k; ++i){
		ans *= (t-i);
		ans /= i;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	set<string> v;
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n=s.length();
	int i=0;
	int j=1;
	while(j<=min(5,n)){
		v.insert(s.substr(i,j));
		if(i==n-j){
			i=0;
			j++;
		}
		else{
			i++;
		}
	}
	string maxx;
	vector<string> q;
	for(auto x : v){
		q.eb(x);
	}
	ll r=q.size();
	sort(q.begin(),q.end());
	cout << q[k-1];

	return 0;
}

Measured memory_bytes: 5116
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <sstream>
#include <cstdio>

using namespace std;

class P{
public:
  int first;
  string second;
  P(){}
  P(int first, string second) : first(first), second(second) {}
  bool operator < (const P& s) const {
    if(first == s.first) return second < s.second;
    return first > s.first;
  }

};

int n;
vector<P> data[26];

main(){
  while(cin >> n && n){
    getchar();
    for(int i=0;i<26;i++) data[i].clear();
    for(int i=0;i<n;i++){
      string input;
      getline(cin, input);
      stringstream ss(input);
      while(ss >> input){
        int c = input[0] - 'a';
        bool f = false;
        for(int i=0;i<data[c].size();i++) if(data[c][i].second == input) ++data[c][i].first, f = true;
        if(!f) data[c].push_back(P(1, input));
      }
    }
    char c;
    cin >> c;
    int idx = c - 'a';
    sort(data[idx].begin(), data[idx].end());
    if(data[idx].size()){
      cout << data[idx][0].second;
      for(int i=1;i<data[idx].size()&&i<5;i++) cout << ' ' << data[idx][i].second;
      cout << endl;
    }else cout << "NA" << endl;
  }
}

Measured memory_bytes: 940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuffer str1=new StringBuffer(sc.nextLine());
		StringBuffer str2=new StringBuffer(sc.nextLine());		
		int len=str1.length();
		if(len!=str2.length()){
			System.out.println("No");
			return;
		}
		while(len-->0){
			StringBuffer sb=new StringBuffer();
			char c=str1.charAt(0);
			sb.append(str1.substring(1));
			sb.append(c);
			str1=sb;
			//System.out.println(str1);
			if(str1.toString().equals(str2.toString())){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  ll ans = 0;
  std::cin >> N;
  std::vector<int> B(N);
  for(int i=0;i<N-1;i++) std::cin >> B[i];
  ans += B[0] + B[N-2];
  for(int i=1;i<N-1;i++) {
    ans += min(B[i-1], B[i]);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m1, m2;
    int d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if (m1 != m2) {
        cout << 1 << "\n";
    } else {
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
  char a[2];
  scanf("%s", a);
  if (a[0] == 'A') printf("T\n");
  else if (a[0] == 'T') printf("A\n");
  else if (a[0] == 'G') printf("C\n");
  else if (a[0] == 'C') printf("G\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int n, a, b; cin >> n >> a >> b;
        if (abs(a - b) % 2 == 0) cout << "Alice\n";
        else cout << "Borys\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a[51],b[51],c[51],d[51],i,j,minv=1e9,minn;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(i=1;i<=m;i++)
		cin>>c[i]>>d[i];
	for(i=1;i<=n;i++){
		minv=1e9;
		for(j=1;j<=m;j++)
			if(abs(c[j]-a[i])+abs(d[j]-b[i])<minv){
				minv=abs(c[j]-a[i])+abs(d[j]-b[i]);
				minn=j;
			}
		cout<<minn<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int C[N-1], S[N-1], F[N-1];
  FOR(i,0,N-1) cin >> C[i] >> S[i] >> F[i];
  FOR(i,0,N-1) {
    int now = S[i] + C[i];
    FOR(j,i+1,N-1) {
      int x = max(0, (now - S[j] + F[j] - 1) / F[j]);
      now = S[j] + F[j] * x + C[j];
    }
    cout << now << endl;
  }
  cout << 0 << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<vector<int> > Matrix;

const int MAX_N = 2e2+10;
const int INF = 1<<30;
Matrix d(MAX_N, vector<int>(MAX_N,INF));
int N, M, R;

void warshall_floyd(){
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (d[j][i]==INF) continue;
      for (int k = 0; k < N; k++) {
        if (d[i][k]==INF) continue;
        d[j][k] = min(d[j][k], d[j][i]+d[i][k]);
      }
    }
  }
}

int ans = 0;

void dfs(int from, int cost, vector<int> vec_r){
	if (vec_r.size()==0) {
		ans = min(ans, cost);
	}
	else {
		for (int i = 0; i < vec_r.size(); ++i) {
			vector<int> temp(vec_r);
			temp.erase(temp.begin()+i);
			dfs(vec_r[i], cost+d[from][vec_r[i]], temp);
		}
	}
}

int main(int argc, char const *argv[])
{
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; ++i) {
		cin >> r[i];
		r[i]--;
	}
	// d = Matrix(N, vector<int>(N,INF));
	for (ll i = 0; i < N; i++) d[i][i]=0;

	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		d[a][b] = c;
		d[b][a] = c;
	}

	warshall_floyd();

	for (int i = 0; i < r.size()-1; ++i) {
		int from=r[i], to=r[i+1];
		ans += d[from][to];
	}

	for (int i = 0; i < r.size(); ++i) {
		vector<int> vec(r);
		vec.erase(vec.begin()+i);
		dfs(r[i], 0, vec);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000009
#define mod 1000000007

int x1, y, x2, y2;

int main()
{
    cin >> x1 >> y >> x2 >> y2;
    cout << x2 - y2 + y << " " << y2 + x2 - x1 << " " << x1 - y2 + y << " " << y + x2 - x1 << " " << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    ans = N
    for n in range(int(N ** 0.5), 0, -1):
        if N % n == 0:
            temp = n + N // n
            if temp < ans:
                ans = temp
    if ans == N:
        print(ans - 1)
    else:
        print(ans - 2)
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

bool judgment(int &t1, int &x1, int &y1, int &t2, int &x2, int &y2) {
  int t = t2 - t1;
  int x = x2 - x1;
  int y = y2 - y1;
  for (int i = t; i >= 0; i = i - 2) {
    if (max(x, -x) + max(y, -y) == i) {
      return true;
    }
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<int> t(N + 1);
  vector<int> x(N + 1);
  vector<int> y(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  
  string result = "Yes";
  
  for (int i = 0; i < N; i++) {
    if(!judgment(t.at(i), x.at(i), y.at(i), t.at(i + 1), x.at(i + 1), y.at(i + 1))) {
      result = "No";
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define out cout
#define in cin
typedef long long ll;
using namespace std;
int main(){
    ll n,k,d,c=0;
    ll freq[101]={0,};
    in >> n >> k;

    ll z;
    for(ll i=1;i<=k;i++){
        in >> d;
        for(ll j=1;j<=d;j++){
            in >> z;
            freq[z]++;
        }
    }

    for(int i=1;i<=n;i++){
        if(freq[i]==0) c++;
    }
    out << c << "\n";

}


Measured memory_bytes: 3588
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int ans[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	char a, b;
	cin >> a >> b;
	//if (a == 'H' && b == 'D') cout << 'H' << endl, exit(0);
	if (a == b) cout << "H" << endl;
	else cout << "D" << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as P
M=10**9+7
n,k=map(int,input().split())
a=P.matrix([list(map(int,input().split()))for i in[0]*n],'O')
b=P.eye(n,n,0,'O')
while k:b=[b,b*a%M][k&1];a=a*a%M;k>>=1
print(b.sum()%M)

Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int X ,Y , Z;
		int count = 0;
		for(X = 0; X <= K; X++){
			for(Y = 0; Y <= K; Y++){
					if(X + Y <= S && S - (X+Y)<= K){
						count++;
					}
				}
		}
		System.out.println(count);

	}

}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0): x( (x % mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if((x += a.x) > mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if(!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(istream& os, const mint& a) { return os << a.x; }

mint f(ll a, ll b) {
	// a<b
	mint x = mint(a+b);
	mint y = mint(b-a+1);
	return x*y/2;
	// return (a+b)*(b-a+1)/2;
}

int main() {
	int n, k;
	cin >> n >> k;
	mint ans = mint(0);

	mint mi,ma,tsum;
	FOR(i,k,n+1) {
		mi = f(0,i-1);
		ma = f(n-i+1,n);
		ans += (ma - mi +1).x;
	}

	cout << ans.x+1 << endl;
	return 0;

}



Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    bool dp[MX]; F0R(i, MX) dp[i] = false;
    dp[0] = true;

    F0R(i, MX) {
        if (!dp[i]) continue;
        F0R(j, 6) {
            if (100 + i + j >= MX) continue;
            dp[100 + i + j] = true;
        }
    }

    int N; cin >> N;
    cout << (dp[N] ? 1 : 0) << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 384
// -- telegram @rentixous --
// -- keep calm and slava ukraini --
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5+1488;

signed main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    for(ll a,i = 1;i<=5;i++){
        cin >> a;
        if(a==0){
            cout<<i<<'\n';
        }
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string str;
int main()
{
    cin>>str;
    int n=(int)str.size();
    ll ans=0;
    int last=0,cur=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]=='1')
        {
            ans+=i/2+1;
            if(last) cur++,last--;
            else last++;
        }
        else
        {
            if(last==1) {cur++; last=0;}
            ans+=cur;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include<iomanip>
#define rep(i, n) for(int i=0 ; i<n; ++i)
#define rep2(i, j, n) for(int i=j; i<n; ++i)
using namespace std;
typedef long long ll;
typedef unsigned long ul;


int main(){
    long double a, b, x;
    double pi=3.1415926535898;
    long double ans, an;
    cin >> a >> b >> x;
    if(x>a*a*b/2){
        an = 2*(b*a*a-x)/a/a/a;
        ans = atan(an)/pi*180;
    }
    else{
        ans = atan(a*b*b/2/x)/pi*180;
    }
    cout<<setprecision(12)<<ans<<endl;
}

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

int main(){
  int n;
  long long a;
  long long max = -1000000;
  long long min = 1000000;
  long long sum = 0;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> a;
    if(a < min)min = a;
    if(a > max)max = a;
    sum += a;
  }
  cout << min << ' ' << max << ' ' << sum << endl;

  return 0;
}



Measured memory_bytes: 3096
N = int(input())
string = input()

rtow = string.count("R")
wtor = 0

anslist = [max(rtow, wtor)]
for c in string:
    if c == "W":
        wtor += 1
    else:
        # c == "R"
        rtow -= 1
    anslist.append(max(rtow, wtor))

print(min(anslist))

Measured memory_bytes: 16904