akhauriyash/Code-Regression huggingface dataset:
sosuu = [2]
A = 55555
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)

a=sosuu

n=int(input())

ans=[]

l=0

for i in a:
  if i%5==1:
    ans.append(str(i))
    l+=1
    
  if l==n:
    break


print(' '.join(ans))

Measured memory_bytes: 66940
#include <stdio.h>
int main(void){
    
    int n,i;
    float x1,x2,x3,x4,y1,y2,y3,y4;
    double AB,CD;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%f %f %f %f %f %f %f %f\n",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        AB=(y2-y1)/(x2-x1);
        CD=(y4-y3)/(x4-x3);
        
        if(AB==CD)
            printf("YES\n");
        
        else
            printf("NO\n");
        
    }
    return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    sc.close();
    int even = n / 2;
    double p = (double) (n - even) / n;
    System.out.println(p);
  }
}

Measured memory_bytes: 21972
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(1){
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0)break;
		bool a[501][501] = {{0}};
		bool mem[501] = {0};
		bool mem1[501] = {0};
		for(int i = 0; i < m; i++){
			int f,t;
			scanf("%d%d",&f,&t);
			a[f][t] = true;
			a[t][f] = true;
		}
		for(int i = 2; i <= n; i++){
			if(a[1][i] || a[i][1])mem[i] = 1;
		}
		for(int i = 2; i <= n; i++){
			for(int j = 2; j <= n; j++){
				if(mem[i] && (a[i][j] || a[j][i])){
					mem1[j] = 1;
				}
			}
		}
		int cnt = 0;
		for(int i = 2; i <= n; i++){
			if(mem1[i] || mem[i])cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

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

    int travel[2][n] = {0};

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

    int mx = INT_MIN;

    for (int i = 0; i < n; i++)
    {
        int sum = 0;

        for (int j = 0; j <= i; j++)
            sum += travel[0][j];

        for (int j = i; j < n; j++)
            sum += travel[1][j];

        mx = max(mx, sum);
    }

    cout << mx << endl;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

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

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 55;
struct P{
    int x,y;
    P(int x = 0,int y = 0):x(x),y(y){;}
    bool operator<(const P &b){
        return (x < b.x)||(x == b.x && (y<b.y));
    }
};

int vis[maxn];
int N;

P points[maxn];

set<pi> sp;

bool valid(P a,P b,int p,int q){
    if(a.x + p == b.x && a.y + q == b.y){
        return true;
    }
    if(a.x - p == b.x && a.y - q == b.y){
        return true;
    }
    return false;
}

int searching(int p,int q){
    int ret = 0;
    memset(vis,0,sizeof(vis));
    _for(i,0,N){
        if(!vis[i]){
            ret++;
            vis[i] = 1;
            P a = points[i];

            _for(j,0,N){
                if(!vis[j] && valid(a,points[j],p,q)){
                        vis[j] = 1;
                        a = points[j];
                }
            }
        }
    }
    return ret;
}

int main()
{
    cin >> N;
    _for(i,0,N){
        int x,y;
        cin >> x >> y;
        points[i] = P(x,y);
    }

    sort(points,points+N);

    _for(i,0,N){
        _for(j,i+1,N){
            P a = points[i];
            P b = points[j];
            sp.insert(make_pair(a.x - b.x,a.y - b.y));
        }
    }

    int ans = N;

    for(auto k: sp){
        int p = k.first;
        int q = k.second;
        //cout << p <<" "<<q << endl;
        ans = min(ans,searching(p,q));
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if(a == 1){
        a += 13;
    }
    if(b == 1){
        b += 13;
    }
    if(a<b){
        cout << "Bob" << endl;
    }else if(a == b){
        cout << "Draw" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long long n,a,b,c,f,i,j,k,s[4001],aa[4001];
while(cin>>n){
if(n==0)break;
for(i=0;i<n;i++){s[i]=0;aa[i]=0;}
for(i=0;i<n;i++){
cin>>a>>b>>c;
k=i;
for(j=0;j<i;j++)if(a==aa[j]){k=j;break;}
aa[i]=a;
for(j=0;j<c;j++){
if(s[k]>=1000000)break;
s[k]+=b;
}
}
for(f=0,i=0;i<n;i++)
if(s[i]>=1000000){cout<<aa[i]<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

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

long long n,k,rez;

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

    cin>>n>>k;

    for(long long i=1;i<=n;i++)
    {
        long long p=n/i;
        long long r=n-i*p;
        rez+=p*max((long long)0,i-k)+max((long long)0,r-k+1);
    }
    if(k==0)
        rez-=n;

    cout<<rez<<endl;

    return 0;
}


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

int main(void){
    vector<string> character;
    character.push_back("");
    character.push_back(".,!? ");
    character.push_back("abc");
    character.push_back("def");
    character.push_back("ghi");
    character.push_back("jkl");
    character.push_back("mno");
    character.push_back("pqrs");
    character.push_back("tuv");
    character.push_back("wxyz");

    int n;
    cin >> n;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.length(); j++){
            int index;
            for(index = j; s[index] != '0'; index++);
            int leng = index - j - 1;
            if(s[j] != '0'){ cout << character[s[j] - '0'][leng % character[s[j] - '0'].length()]; }
            j = index;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
map<ll, ll> mem;

ll func(ll m) {
	if (m == 1) return 1;
	if (m == 0) return 0;
	if (mem.count(m) != 0) return mem[m];
	if (m % 2 == 1) {
		ll ret = (2 * func(m / 2) + func(m / 2 + 1)) % mod;
		return mem[m] = ret;
	}
	else {
		ll ret = (2 * func(m / 2) + func(m / 2 - 1)) % mod;
		return mem[m] = ret;
	}
}

int main() {
	ll n; cin >> n;
	cout << func(n + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int height[10];
int top[3] = {0};
int i;

for (i = 0; i < 10; i++) {
scanf("%d", &height[i]);
}

top[0] = height[0];

for (i = 1; i < 10; i++) {
if (height[i] >= top[0]) {
top[2] = top[1];
top[1] = top[0];
top[0] = height[i];
}
else if(height[i] >= top[1]) {
top[2] = top[1];
top[1] = height[i];
}
else if (height[i] >= top[2]) {
top[2] = height[i];
}
}

for(i = 0; i < 3; i++) {
printf("%d\n", top[i]);
}

return 0;
}




Measured memory_bytes: 2040
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 1e9+7;
const int SQ =320;
const long double EPS = 1e-7;
int a[N], n;
struct segTree{
  int t[N<<2];
  segTree(){memset(t,0,sizeof t);}
  int pull(int i, int j){
    if(a[i]<a[j])return i;
    return j;
  }
  void activate(int idx, int node = 1, int s = 1, int e = n){
    if(s==e){
      t[node] = s;
    } else {
      int md = (s + e) >> 1;
      if(idx <= md)
        activate(idx,node<<1,s,md);
      else
        activate(idx,node<<1|1,md+1,e);
      t[node]=pull(t[node<<1],t[node<<1|1]);
    }
  }
  int qry(int l, int r, int node = 1, int s = 1, int e = n){
    if(r<s||e<l||l>r)return 0;
    if(l<=s&&e<=r)
      return t[node];
    int md = (s + e) >> 1;
    return pull(qry(l,r,node<<1,s,md),qry(l,r,node<<1|1,md+1,e));
  }
}oddTree, evenTree;
map<ii,vector<ii>> adj;
ii solve(int s, int e){
  if(s>e)return ii(0,0);
  if((s&1)==(e&1)){
    cout<<s<<' '<<e<<endl;
    exit(0);
  }
  // assert((s&1)!=(e&1));
  if(s&1^1){
    int x = evenTree.qry(s,e);
    int nxtX = oddTree.qry(x+1,e);
    if(nxtX==0){
      x = evenTree.qry(s,e-2);
      nxtX=oddTree.qry(x+1,e);
    }
    ii val = (make_pair(a[x],a[nxtX]));
    vector<ii> vp;
    vp.pb(solve(s,x-1));  if(vp.back().F==0)vp.pop_back();
    vp.pb(solve(x+1,nxtX-1));  if(vp.back().F==0)vp.pop_back();
    vp.pb(solve(nxtX+1,e));  if(vp.back().F==0)vp.pop_back();
    adj[val]=vp;
    return val;
  } else {
    ///lazm el a5do yb2a odd
    int x = oddTree.qry(s,e);
    int nxtX = evenTree.qry(x+1,e);
    if(nxtX==0){
      x = oddTree.qry(s,e-2);
      nxtX=evenTree.qry(x+1,e);
    }
    ii val = (make_pair(a[x],a[nxtX]));
    vector<ii> vp;
    vp.pb(solve(s,x-1));  if(vp.back().F==0)vp.pop_back();
    vp.pb(solve(x+1,nxtX-1));  if(vp.back().F==0)vp.pop_back();
    vp.pb(solve(nxtX+1,e));  if(vp.back().F==0)vp.pop_back();
    adj[val]=vp;
    return val;
  }
}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  cin >> n;
  a[0] = INT_MAX;
  f(i,1,n+1){
    cin >> a[i];
    if(i&1)oddTree.activate(i);
    else evenTree.activate(i);
  }
  priority_queue<ii,vector<ii>,greater<ii>>pq;

  pq.push(solve(1,n));

  while(pq.size()){

    auto cur = pq.top();  pq.pop();
    cout << cur.F << ' ' << cur.S << ' ';
    for(auto v : adj[cur])pq.push(v);

  }



  return 0;
}


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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int f = (c+b-1) / b;
    int f2 = (a+d-1) / d;
    if(f <= f2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
    ll ans = 0;
    int n;
    cin >> n;
    int a[n];
    rep(i, n){
        cin >> a[i];
    } 

    rep(i, n){
        if(i-1 < 0){
            ans += abs(a[i]);
        }else{
            ans += abs(a[i]-a[i-1]);
        }
    }
    ans += abs(a[n-1]-0);

    rep(i, n){
        int before;
        int after;
        if(i-1 < 0){
            before = 0;
        }else{
            before = a[i-1];
        }
        if(i+1 >= n){
            after = 0;
        }else{
            after = a[i+1];
        }
        int temp = ans-abs(a[i]-before)-abs(a[i]-after);
        temp += abs(before-after);

        cout << temp << endl;
    }
}

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


Measured memory_bytes: 1664
import math

def InvMod(i, pow, mod): #累乗のmodを計算
    if pow == 1:
        return i % mod
    else:
        if pow % 2 == 0:
            return InvMod((i**2) % mod, pow//2, mod) % mod
        else:
            return InvMod((i**2) % mod, pow//2, mod) * i % mod

def Prime(i): #素数であればTrueを返す
    root = math.sqrt(i)
    j, div = 2, True
    while j <= root:
        if i % j == 0:
            div = False
            break
        j += 1
    return div

N, M = map(int, input().split())
max = int(math.sqrt(M))
mod = 7 + 10**9

Pinv = [0]
Pfact = 1
for i in range(1, 31): #(階乗)^-1の計算, 2^31 > 10^9なので30!^-1まで求めれば十分
    Pfact *= i
    Pfact %= mod
    Pinv.append(InvMod(Pfact, mod-2, mod))

P = []
for i in range(2, max+1): #素因数の列挙
    if M % i == 0:
        if Prime(i):
            P.append(i)
        if Prime(M//i) and i**2 != M:
            P.append(M//i)

ans = 1
for p in P:
    C, pow = M, 0
    while C % p == 0: 
        pow += 1
        C //= p
    comb = Pinv[pow]  #(N-1)!/pow!(N-1)!
    for i in range(pow): #comb * (N-1+1)(N-1+2)…(N-1+pow)
        comb *= (N+i)
        comb %= mod
    ans *= comb
    ans %= mod

print(ans)



Measured memory_bytes: 3064
N = int(input())
 
A = list(map(int, input().split()))
 
L = {}
R = {}
 
for i in range(N):
  t = A[i]+i
  if t in L:
    L[t] += 1
  else:
    L[t] = 1
  s = i - A[i]
  if s in R:
    R[s] += 1
  else:
    R[s] = 1  
#print(L,R)
ans = 0
for i in range(N):
  t = A[i]+i
  #ans += R[t]
  if t in R.keys():
    ans += R[t]
    #print(t,R[t])
print(ans)

Measured memory_bytes: 56564
#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

LL dp[304][304][304];
vector<pii> rsts[304];

void mainmain(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int l, r, x;
		cin >> l >> r >> x;
		rsts[r].emplace_back(l, x);
	}

	LL ans = 0;
	dp[0][0][0] = 1;
	for(int i = 0; i <= n; ++i)
	for(int j = 0; j <= n; ++j)
	for(int k = 0; k <= n; ++k){
		LL &a = dp[i][j][k];
		a %= MOD;
		int t = max({i, j, k});

		for(cauto p : rsts[t]){
			int l = p.first;
			if((i >= l) + (j >= l) + (k >= l) != p.second){
				a = 0;
				break;
			}
		}
		
		if(t == n){
			ans += a;
		}
		else{
			dp[t + 1][j][k] += a;
			dp[i][t + 1][k] += a;
			dp[i][j][t + 1] += a;
		}
	}
	ans %= MOD;
	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: 219392
n=gets.chomp.to_i
t,a=gets.chomp.split(" ").map(&:to_i)
h=gets.chomp.split(" ").map(&:to_i)


def test(n,t,a,h)
  puts h.map.with_index {|x,i|{i: i, v: (a.-(t.-x*0.006)).abs}}.sort{|a,b| a[:v]<=>b[:v] }.first[:i].next
end

test(n,t,a,h)

Measured memory_bytes: 2172
#include<stdio.h>
#include<string.h>
int main(void)
{
	char buf[101];
	int michi[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
	int x,i,len,p,flg;
	
	while(1)	{
		scanf("%s",buf);
		if(strcmp(buf,"#")==0)	break;
		len=strlen(buf);
		x=0;
		flg=1;
		for(i=0;i<len;i++)	{
			p=buf[i]-'0';
			x=michi[x][p];
			if(x==-1)	{
				flg=0;
				break;
			}
		}
		if(x!=5)	{
			flg=0;
		}
		if(flg==0)	{
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
	}
	return 0;
}


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


int main(){
    ll n; cin >> n;
    int fx=0, temp=n;
    rep(i,8){
        fx += temp % 10;
        temp /= 10;
    }
    if(n % fx == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
const int MOD=1000000007;
int main(){
  int n;
  int check[100005]={0};
  cin>>n;
  if(n%2==1){
    for(int i=0;i<n;i++){
      int data;
      cin>>data;
      check[data/2]++;
    }
    for(int i=1;i<=n/2;i++){
      if(check[i]!=2){
	cout<<0<<endl;
	return(0);
      }
    }
    if(check[0]!=1){
      cout<<0<<endl;
      return(0);
    }
  }else{
    for(int i=0;i<n;i++){
      int data;
      cin>>data;
      check[(data-1)/2]++;
    }
    for(int i=0;i<n/2;i++){
      if(check[i]!=2){
	cout<<0<<endl;
	return(0);
      }
    }
  }    

  int bin=1;
  for(int i=0;i<n/2;i++){
    bin=(bin*2)%MOD;
  }
  cout<<bin<<endl;
  return(0);
}


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

int main() {
  long long H,M,H2,M2,K;
  cin >> H >> M >> H2 >> M2 >> K;
  
  M += H * 60;
  M2 += H2 * 60;
  
  cout << M2 - M - K << endl;
}

Measured memory_bytes: 3596
fun main (args : Array<String>) {
	val (a, b) = readLine()!!.split(" ")
	val A : Int = a.toInt()
	val B : Int = b.toInt()
	if ((B * 2) > A) {
		println("0")
	} else {
		val calc = A - (B * 2)
		println("${calc}")
	}
}

Measured memory_bytes: 37764
#include<iostream>
using namespace std;
int main() {
	string S;
	cin >> S;

	bool flag = false;
	if (S.at(0) == 'A') {
		int sum = 0;
		for (int i = 2; i < S.size() - 1; i++)
			if (S.at(i) == 'C')
				sum++;
		if (sum == 1) {
			bool flag2 = true;
			for (int i = 1; i < S.size(); i++)
				if (S.at(i) >= 'A'&&S.at(i) <= 'Z'&&S.at(i) != 'C') {
					flag2 = false;
					break;
				}
			if (flag2)
				flag = true;
		}
	}
	if (flag)
		cout << "AC " << endl;
	else
		cout << "WA" << endl;
	return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
P    = list(map(int, input().split()))

q = sum(P[:K])
m = q

for k in range(N-K+1):
    if k > 0:
        q = q - P[k-1] + P[K-1+k]
    if m < q:
        m = q

print((m+K)/2)


Measured memory_bytes: 24808
#include<stdio.h>

int main(){
  long long x;
  scanf("%lld",&x);
  
  for(long long a=0;a>=0;a++){
    if(a<64){
      for(long long b=-64;b<=a;b++){
        if(a*a*a*a*a-b*b*b*b*b==x){printf("%lld %lld",a,b);return 0;}
      }
    }
    if(a>=64){
      for(long long b=1;b<=2*a;b++){
        if(a*a*a*a*a-b*b*b*b*b==x){printf("%lld %lld",a,b);return 0;}
      }
    }
  }
}


Measured memory_bytes: 1732
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (x, y, x2, y2) = intList()
    val a = x2 - x
    val b = y2 - y
    println("${x2 - b} ${y2 + a} ${x - b} ${y + a}")
}

Measured memory_bytes: 35980
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  vector<int> kind;
  kind.push_back(0);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=1;i<N;i++){
    if(vec[i-1]!=vec[i]){
      kind.push_back(i);
    }
  }
  kind.push_back(N);
  vector<int> kind2;
  for(int i=1;i<kind.size();i++){
    kind2.push_back(kind[i]-kind[i-1]);
  }
  sort(kind2.begin(),kind2.end());
  
  
  int ans=0;
  
  if((int)kind2.size()-K>0){
    for(int i=0;i<(int)kind2.size()-K;i++){
      ans+=kind2[i];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3316
n,x=map(int,input().split())
for i in range(n+1):
        for j in range(n+1):
                z=x-(10000*i+5000*j)
                if z%1000==0:
                        z//=1000
                        if 0<=z and i+j+z==n:
                                print(i,j,z)
                                exit()
print(-1,-1,-1)


Measured memory_bytes: 40684
n = int(input())
h = [int(i) for i in input().split()]

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
    
# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))

print(dp[n-1])

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

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

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}



int main(){

    ll N;
    cin >> N;

    ll d[N+1];
    ll A[N];
    rep(i, N+1){
        d[i] = 0;
    }
    rep(i, N) {

        cin >> A[i];
        d[A[i]]++;
    }

    ll ans = 0;
    rep(i, N+1) {
        ans += (d[i] * (d[i] - 1)) / 2;
    }

    rep(i, N) {
        ll ou =  ans - (d[A[i]] * (d[A[i]] - 1) / 2) + ((d[A[i]] - 2)* (d[A[i]] - 1) / 2);
        cout << ou << endl;
    }

}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    ll maxi = 0;
    cin >> S;
    for(ll i = 0;i < S.size();i++) {
        ll count = 0;
        for(ll j = i;i < S.size();j++) {
            if(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') {
                count++;
            } else {
                break;
            }
        }
        maxi = max(maxi, count);
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
S = list(map(int, list(input())[: -1]))
res = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      check = 0
      for x in range(N):
        if check == 0 and (S[x] == i):
          check += 1
        elif check == 1 and (S[x] == j):
          check += 1
        elif check == 2 and (S[x] == k):
          check += 1
          break
      if check == 3:
        res += 1
print(res)

Measured memory_bytes: 44764
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,M;
    int[] P;
    int[] x,y;

    int[] union;

    private void init(int N) {
        union = new int[N];
        for(int i = 0;i < N;i++) {
            union[i] = i;
        }
    }

    private int root(int a) {
        return union[a] == a ? a : root(union[a]);
    }

    private void unite(int a,int b) {

        a = root(a);
        b = root(b);

        if (a ==  b) {
            return;
        }

        if (a < b) {
            union[b] = a;
        } else {
            union[a] = b;
        }
    }

    private void solve() {
        N = nextInt();
        M = nextInt();

        P = new int[N];
        for(int i = 0;i < N;i++) {
            P[i] = nextInt()-1;
        }

        x = new int[M];
        y = new int[M];
        for(int i = 0;i < M;i++) {
            x[i] = nextInt()-1;
            y[i] = nextInt()-1;
        }

        init(N);

        for(int i = 0;i < M;i++) {
            unite(x[i],y[i]);
        }
        int ans = 0;
        for(int i = 0;i < N;i++) {
            if (i == P[i] || root(i) == root(P[i])) {
                ans++;
            }
        }

        out.println(ans);
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 43616
import java.util.AbstractMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int w=scan.nextInt();
        int h=scan.nextInt();
        int[] dx=new int[8];
        int[] dy=new int[8];
        dx[0]=1;dx[1]=0;dx[2]=0;dx[3]=-1;dx[5]=1;dx[6]=-1;dx[7]=1;dx[4]=-1;
        dy[0]=0;dy[1]=1;dy[2]=-1;dy[3]=0;dy[5]=1;dy[6]=-1;dy[7]=-1;dy[4]=1;
        while(w>0&&h>0){
            int ans=0;
            char[][] c=new char[60][60];
            boolean[][] color=new boolean[60][60];
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    c[i][j]=scan.next().charAt(0);
                    color[i][j]=false;
                }
            }
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(color[i][j]==true)continue;
                    if(c[i][j]=='0')continue;
                    Queue<AbstractMap.SimpleEntry<Integer, Integer>> Q = new LinkedList<>();
                    AbstractMap.SimpleEntry<Integer, Integer> start = new AbstractMap.SimpleEntry<>(i, j);
                    Q.offer(start);
                    color[i][j]=true;
                    while(!(Q.size()==0)){
                        AbstractMap.SimpleEntry<Integer, Integer> now=Q.poll();
                        int x=now.getKey();
                        int y=now.getValue();
                        for(int k=0;k<8;k++){
                            int nx=x+dx[k];
                            int ny=y+dy[k];
                            if(nx>=0&&nx<h&&ny>=0&&ny<w){
                                if(color[nx][ny]==false&&c[nx][ny]=='1'){
                                    AbstractMap.SimpleEntry<Integer, Integer> nxy = new AbstractMap.SimpleEntry<>(nx,ny);
                                    color[nx][ny]=true;
                                    Q.offer(nxy);
                                }
                            }
                        }
                    }
                    ans++;
                }
            }
            System.out.println(ans);
            w=scan.nextInt();
            h=scan.nextInt();
        }
    }
}


Measured memory_bytes: 41724
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>

int main() {
	std::string str; std::cin >> str;
	std::vector<int> count(26, 0);
	for (const auto c : str) {
		count[c - 'A'] ++;
	}
	auto is_collect = true;
	for (const auto c : count) {
		if (c != 2 && c != 0) {
			is_collect = false;
			break;
		}
	}
	if (is_collect) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
N=str(input())
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
for i in range(2):
  for j in range(2):
    for k in range(2):
      t=a
      if i==0:
        t+=b
      else:
        t-=b
        
      if j==0:
        t+=c
      else:
        t-=c
        
      if k==0:
        t+=d
      else:
        t-=d
        
      if t==7:
        print("{}{}{}{}{}{}{}=7".format(a,"+-"[i],b,"+-"[j],c,"+-"[k],d))
        exit()
        

        
  


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

typedef unsigned int uint;

int main( void )
{
    uint surrounding, nHouse;
    std::cin >> surrounding >> nHouse;
    
    std::vector<uint> positions(nHouse);
    for ( auto & pos : positions )
    {
        std::cin >> pos;
    }
    
    uint maxDist = surrounding - positions[ nHouse-1 ] + positions[0];
    
    for ( uint i = 1; i < nHouse; ++i )
    {
        uint tmpDist = positions[i] - positions[i-1];
        if ( tmpDist > maxDist )
        {
            maxDist = tmpDist;
        }
    }
    
    std::cout << surrounding - maxDist << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    if(a+b >= c){
        cout << "No" << endl;
        return 0;
    }
    long long e = (c - a - b) * (c - a - b) - 4*a*b;
    if(e > 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()
l = len(S)
d = {0:0}
mod10n = 1
for i in range(1, len(S)+1):
    s = int(S[l-i])
    d[i] = (d[i-1] + s * mod10n) %2019
    mod10n = (mod10n * 10) % 2019
count_d = defaultdict(int)
for key in d.keys():
    count_d[d[key]] += 1
counter = 0
for key in count_d.keys():
    counter += (count_d[key] * (count_d[key]-1)) //2

print(counter)


Measured memory_bytes: 101488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string S;
	cin >> S;
	int counter = 0;
	for (char ox : S) {
		if (ox == 'o') {
			counter++;
		}
	}
	cout << 700 + counter * 100;

	return 0;
}

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

int main(void){
    int N; cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    int ans = 0;
    for(int i = 0; i < N-1; i++){
        if(p[i] == i+1){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[N-1] == N) swap(p[N-2],p[N-1]), ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        int cnt_l=0;
        int cnt_r=0;
        int l=0;
        for (int i=0;i<N;i++) {
            if (S.charAt(i)=='(') {
                cnt_l++;
            } else {
                cnt_r++;
            }
            l=Math.max(l, cnt_r-cnt_l);
        }
        cnt_l=0;
        cnt_r=0;
        int r=0;
        for (int i=N-1;i>=0;i--) {
            if (S.charAt(i)=='(') {
                cnt_l++;
            } else {
                cnt_r++;
            }
            r=Math.max(r, cnt_l-cnt_r);
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<l;i++) {
            sb.append('(');
        }
        sb.append(S);
        for (int j=0;j<r;j++) {
            sb.append(')');
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main(void)
{
	int N,A,B,C,X;
	int Y[101];
	while(cin>>N>>A>>B>>C>>X){
		if(!(N||A||B||C||X)) break;
		for(int i=0; i<N; i++){
			cin >> Y[i];
		}
		int flame=0;
		int rel=0;
		while(flame<10001){
			if(X==Y[rel]) rel++;
			if(rel==N) break;
			flame++;
			X = (A*X+B)%C;
		}
		if(flame<10001){
			cout<<flame<<endl;
		}else{
			cout<<"-1"<<endl;
		}
	}
			
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll INF=1LL<<60;
const int MOD=998244353;
const int N=2e5+5;



int main(){
    int N; cin >> N;
    string S; cin >> S;
    int res=0;
    for(int i=0; i<N-2; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    char str[25];
    int i;
    
    scanf("%s", str);
    for(i = (strlen(str)-1); i >= 0; i--)
    {
        putchar(str[i]);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define INF 1000000000000000000LL

int main() {
	ll n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	rep(i, 0, n - 1) {
		ll c, d;
		cin >> c >> d;
		long long low = 1;
		long long high = INF/(c+d);

		while (low < high) {
			long long mid = (high + low) >> 1;

			if (mid*c >=a && mid*d >= b) {
				high = mid;
			}
			else {
				low = mid + 1;
			}
		}
		a = low*c;
		b = low*d;
	}
	cout << a+b << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort(), x_n.sort()

    x_p_sum = defaultdict(int, {0: 1})
    x_n_sum = defaultdict(int, {0: 1})
    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = 0
    for i in x_p_sum:
        if i in x_n_sum:
            res += (x_n_sum[i] * x_p_sum[i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

bool visited[200005];
int a[200005],visitedTime[200005],timeVisited[200005];

int main()
{
    FAST();
    long long k;
    int i,n,x=1,y,cnt=0;
    cin >> n >> k;
    for(i=1;i<=n;i++)cin >> a[i];
    while(k > 0)
    {
        if(visited[x])
        {
            y=cnt-timeVisited[x]+1;
            ++k;
            if(k%y == 0)cout << visitedTime[cnt];
            else cout << visitedTime[timeVisited[x]+(k%y)-1];
            return 0;
        }
        --k;
        visited[x]=true;
        timeVisited[x]=++cnt,visitedTime[cnt]=x,x=a[x];
    }
    cout << x;
    return 0;
}


Measured memory_bytes: 5968
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

int n;

bool ch(vector<vector<P>> &da, bitset<15> now){
    rip(i,n,0){
        if(now[i]){
            rip(j, da[i].size(), 0){
                if(da[i][j].second != now[da[i][j].first]){
                    return false;
                }
            }
        }
    }
    return true;
}

int main(){
    cin >> n;
    vector<vector<P>> da(n);
    rip(i,n,0){
        int a;cin >> a;
        da[i] = vector<P>(a);
        rip(j,a,0){
            cin >> da[i][j].first >> da[i][j].second;
            da[i][j].first --;
        }
    }
    int co = 1;
    rip(i,n,0){
        co *= 2;
    }
    int ans = 0;
    rip(i,co,0){
        bitset<15> now(i);
        if(ch(da,now)){
            ans = max(int(now.count()), ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (n, k) = sc.intList()
        val l = sc.intList().sortedBy { -it }
        var sum = 0
        for (i in 0 until k) {
            sum += l[i]
        }

        println(sum)
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 38212
#include <iostream>
#include <cstring>
#include <vector>
#define ll long long
using namespace std;
const ll maxr = 200000;
const ll oo = 4000000000;
ll R,C,N;
ll r[maxr+1],c[maxr+1],a[maxr+1];
ll m,head[maxr*2+1],link[maxr*2+1],adj[maxr*2+1],we[maxr*2+1],wv[maxr*2+1];
ll tplt;
vector<ll> V[maxr*2+1];
bool visit[maxr*2+1];
void addEdge(ll x,ll y,ll w)
{
	m++;
	link[m]=head[x];
	adj[m]=y;
	we[m]=w;
	head[x]=m;
	m++;
	link[m]=head[y];
	adj[m]=x;
	we[m]=w;
	head[y]=m;
}
void dfs(ll x)
{
	V[tplt].push_back(x);
	ll i=head[x];
	while (i!=0)
	{
		ll y=adj[i];
		if (wv[y]==-oo)
		{
			wv[y]=we[i]-wv[x];
			dfs(y);
		}
		i=link[i];
	}
}
bool check(ll x)
{
	visit[x]=true;
	ll i=head[x];
	bool res=true;
	while (i!=0)
	{
		ll y=adj[i];
		if (we[i]!=wv[y]+wv[x])
			res=false;
		if (!res) return res;
		if (!visit[y]) res&=check(y);
		if (!res) return res;
		i=link[i];
	}
	return res;
}
int main() 
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> R >> C >> N;
	m=0;
	memset(head,0,sizeof(head));
	for (ll i=1; i<=N; i++)
		{
			cin >> r[i] >> c[i] >> a[i];
			addEdge(r[i],R+c[i],a[i]);
			addEdge(R+c[i],r[i],a[i]);
		}
	for (ll i=1; i<=R+C; i++)
		wv[i]=-oo;
	tplt=0;
	for (ll i=1; i<=R+C; i++)
		if (wv[i]==-oo)
		{
			wv[i]=0;
			tplt++;
			V[tplt].clear();
			dfs(i);
			ll min1=oo,min2=oo;
			for (auto it=V[tplt].begin(); it!=V[tplt].end(); it++)
			{
				if (*it<=R) min1=min(min1,wv[*it]);
				else
				min2=min(min2,wv[*it]);
			}
			if (min1+min2<0)
			{
				cout << "No";
				return 0;
			}
		}
	/*for (ll i=1; i<=R; i++)
		cout << wv[i] << ' ';
	cout << '\n';
	for (ll i=R+1; i<=R+C; i++)
		cout << wv[i] << ' ';
	cout << '\n';*/
	memset(visit,false,sizeof(visit));
	for (ll i=1; i<=R+C; i++)
		if (!visit[i])
		{
			if (!check(i))
			{
				cout << "No";
				return 0;
			}
		}
	cout << "Yes";
	return 0;
}

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

int main(){
    int x[4][3][10] = {};
    int n, b, f, r, v;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        x[b-1][f-1][r-1] += v;
    }
    // output
    for (int b = 0; b < 4; b++){
        for (int f = 0; f < 3; f++){
            for (int r = 0; r < 10; r++){
                cout << " " << x[b][f][r];
            }
            cout << endl;
        }
        if (b != 3){
            cout << "####################" << endl;
        }
    }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string toy[N];
    for(int i=0; i<N; i++){
        cin >> toy[i];
    }
    sort(toy,toy+N);
    int ans=1;
    for(int i=1; i<N; i++){
        if(toy[i].compare(toy[i-1])!=0) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9888
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	int a, b, c;
	int ans = 0;
	cin >> a >> b;
	if (a < b)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

	return 0;
	
}


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

#define N 200123
#define mod 1000000007

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int a, b; cin >> a >> b;
    a--; b--;
    cout << (b+a-1)/a <<"\n";
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int mod = 1000000007;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = Math.min(n*a, b);
		System.out.println(ans);
		sc.close();
		
	}
}


Measured memory_bytes: 23764
H, W = map(int, input().split())

ans = 0
if H == 1 or W == 1:
    ans = 1
elif W % 2 == 0:
    ans = W // 2 * H
else:
    e = (W + 1) // 2
    o = W // 2
    ans = (e + o) * (H // 2)
    if H % 2 == 1:
        ans += e
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x;
  int maximum = INT_MIN, minimum = INT_MAX;
  for(int i = 0; i < n; i++){
    cin >> x;
    maximum = max(maximum, x - minimum);
    minimum = min(minimum, x);
  }
  cout << maximum << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  REP(i, h) REP(j, w) cin >> a[i][j];
  char r[h][w], b[h][w];
  // 赤いマス
  REP(i, h) REP(j, w) {
    if (j == w - 1) {
      r[i][j] = '.';
    } else {
      if (i % 2 == 0 || j == 0 || a[i][j] == '#') {
        r[i][j] = '#';
      } else {
        r[i][j] = '.';
      }
    }
  }
  // 青いマス
  REP(i, h) REP(j, w) {
    if (j == 0) {
      b[i][j] = '.';
    } else {
      if (i % 2 || j == w - 1 || a[i][j] == '#') {
        b[i][j] = '#';
      } else {
        b[i][j] = '.';
      }
    }
  }
  REP(i, h) {
    REP(j, w) cout << r[i][j];
    cout << "\n";
  }
  cout << "\n";
  REP(i, h) {
    REP(j, w) cout << b[i][j];
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 1408
def search(N,adj):
    visited={1:[1]}
    S=[[1]]
    paths=[]
    while len(S)!=0:
        p=S.pop()
        if len(p)==N:
            paths.append(p)
        else:
            for w in adj[p[-1]]:
                if w not in p:
                    S.append(p+[w])
    return paths


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    ad={x:[] for x in range(1,N+1)}
    for i in range(M):
        a,b=list(map(int,input().split()))
        ad[a].append(b)
        ad[b].append(a)
    print(len(search(N,ad)))












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

int main(){
 vector<int> a(3);
 for(int i=0;i<3;i++){
   cin >> a.at(i);
 }
 int k;
 cin >> k ;
 sort(a.begin(),a.end());
 for(int i=0;i<k;i++){
   a.at(2)*=2;
 }
 cout << a.at(0)+a.at(1)+a.at(2) << endl;
}


Measured memory_bytes: 256