akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	int a[n],ans=INT_MAX;
	for(int i = 0 ; i < n ; i++ ){
		cin >> a[i];
	}
	int k = 0;
	for(int i = 1 ; i <=100 ; i ++ ){
		k = 0;
		for(int j = 0 ;j < n ; j ++ ){
			k+=(abs(a[j]-i))*((abs(a[j]-i)));
		}
		ans = min(ans,k);
	}
	cout<<ans;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

public class Main {
  private static long solve(long a, long b, long c) {
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
      return 0;
    }
    long[] as = new long[]{a, b, c};
    Arrays.sort(as);
    return as[0] * as[1];
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long a = reader.nextLong();
    long b = reader.nextLong();
    long c = reader.nextLong();
    out.println(solve(a, b, c));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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

using namespace std;

//#define FILE_IO

int N;
int v[100005], ord[100005];

bool cmp(int a, int b)
{
    return v[a] < v[b];
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]), ord[i] = i;
    sort(ord + 1, ord + N + 1, cmp);
    for(int i = 1; i <= N; i++)
        v[ ord[i] ] = i;

    int w1 = 0, w2 = 0;
    for(int i = 1; i <= N; i += 2)
        if(v[i] % 2 != i % 2)
            w1++;
    for(int i = 2; i <= N; i += 2)
        if(v[i] % 2 != i % 2)
            w2++;

    int ans = 0;
    if(w1 > w2) swap(w1, w2);
    ans += w1;
    w2 -= w1;
    ans += w2;
    if(w2 % 2 == 1) ans++;

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

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    vector<int> v;
    
    for(int x=1; x<100; x++){
        for(int y=1; y<100; y++){
            for(int z=1; z<100; z++){
                ll sum = 0;
                sum = x*x + y*y + z*z + x*y + y*z + z*x;
                if(sum<=10050) v.push_back(sum);
            }
        }
    }
    sort(all(v));
    
    for(int i=1; i<=n; i++){
        cout << count(all(v), i) << ln;
    }
    return 0;
}

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

int min( int a, int b )
{
    if( a < b )
        return a;
    else
        return b;
}

int main()
{
    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;

    cout << min( min( a, b ), ( b, c ) ) + min( d, e ) - 50 << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
struct Edge{
	int v,c,nxt;
}e[400010];int tot=1;
int first[200010];
void build(int u,int v,int c)
{
	e[++tot]=(Edge){v,c,first[u]};
	first[u]=tot;
	return ;
}
void adde(int u,int v,int c)
{
	build(u,v,c);
	build(v,u,0);
	return ;
}
int S,T;
queue<int>q;
int dep[200010];
bool bfs()
{
	for(int i=S;i<=T;i++)
		dep[i]=0;
	dep[S]=1;q.push(S);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=first[u];i;i=e[i].nxt)
			if(e[i].c&&!dep[e[i].v])
			{
				dep[e[i].v]=dep[u]+1;
				q.push(e[i].v);
			}
	}
	return dep[T]>0;
}
int cur[200010];
int dfs(int u,int flow)
{
	if(u==T)return flow;
	for(int &i=cur[u];i;i=e[i].nxt)
		if(e[i].c&&dep[e[i].v]==dep[u]+1)
		{
			int d=dfs(e[i].v,min(flow,e[i].c));
			if(d){
				e[i].c-=d;
				e[i^1].c+=d;
				return d;
			}
		}
	return 0;
}
int dinic()
{
	int ans=0;
	while(bfs())
	{
		for(int i=S;i<=T;i++)
			cur[i]=first[i];
		int d;
		while(d=dfs(S,1e9))
			ans+=d;
	}
	return ans;
}
int P[100010],Q[100010];
int x[100010],y[100010];
int main()
{
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&P[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&Q[i]);
	int A=0,B=0;
	for(int i=0;i<n;i++)
		if(!x[i]){
			int now=i;A++;
			do{
				x[now]=A;
				now=P[now];
			}while(now!=i);
		}
	for(int i=0;i<n;i++)
		if(!y[i]){
			int now=i;B++;
			do{
				y[now]=B;
				now=Q[now];
			}while(now!=i);
		}
	S=0;T=A+B+1;
	int ans=0;
	for(int i=0;i<n;i++)
		if(P[i]==i&&Q[i]==i)ans++;
		else if(P[i]==i)adde(A+y[i],T,1);
		else if(Q[i]==i)adde(S,x[i],1);
		else{
			adde(A+y[i],x[i],1);
			if(P[i]==Q[i])adde(x[i],A+y[i],1);
		}
	ans+=dinic();
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 10240
#include<stdio.h>

int main() {
	int N;
	scanf("%d", &N);
	int a[N];
	int o = 0, t = 0, f = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0) {
			if (a[i] % 4 == 0) {
				f++;
			} else {
				t++;
			}
		} else {
			o++;
		}
	}
	if (f == 0) {
		if (o == 0) {
			printf("Yes");
			return 0;
		} else {
			printf("No");
			return 0;
		}
	} else {
		if (f >= o) {
			printf("Yes");
			return 0;
		}
		if (o - f == 1) {
			if (t == 0) {
				printf("Yes");
				return 0;
			} else {
				printf("No");
				return 0;
			}
		}
		if (o - f > 1) {
			printf("No");
			return 0;
		}
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = Integer.parseInt(in.next());
		int b = Integer.parseInt(in.next());
		int c = Integer.parseInt(in.next());
		int count = 0;
		
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}	


Measured memory_bytes: 26200
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  rep(i,0,N){
      cin >> data[i];
  }
  int check = 0;
  rep(i,0,N){
      if(data[i]%2==0){
          if(data[i]%3!=0&&data[i]%5!=0){
              check=1;
              break;
          }
      }
  }
  if(check==1){
      cout<<"DENIED"<<endl;

  }else{
      cout << "APPROVED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, *A = map(int, read().split())
Aarr = np.array(A)
At = 1 / Aarr
print(1 / sum(At))


Measured memory_bytes: 12504
apt = Array.new(4){Array.new(3){Array.new(10,0)}}

gets
while ( info = gets )
  b,f,r,v = info.split.map(&:to_i)
  apt[b-1][f-1][r-1] += v
end
apt.each.with_index(0) do |bldg,i|
  puts "#"*20 if i > 0
  bldg.each do |floor|
    puts " " + floor.join(" ")
  end
end

Measured memory_bytes: 8744
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007 //1e9+7
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,ans,cnt=0;
    string s;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;
using namespace std;
int N, K, S;
int calc(int n, int k, int s, int count) {
    if (s == S && k == K) {
        return ++count;
    }
    if (n > N || s > S) {
        return count;
    }
    
    count = calc(n + 1, k + 1, s + n, count);
    
    return calc(n + 1, k, s, count);
}
int main()
{
    while (cin >> N >> K >> S, N | K | S) {
        cout << calc(1, 0, 0, 0) << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main() {
  string s;
  cin >> s;
  vector<bool> exist(26, false);
  for (int i = 0; i < s.length(); i++) {
    exist[s[i] - 'a'] = true;
  }
  for (char i = 'a'; i <= 'z'; i++) {
    if (!exist[i - 'a']) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b >= c)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
@{$_ x3}=1for A..D;for$i(1..<>-1){$x=0;for$j(glob'{A,B,C,D}'x3){$j=~/../,($$j[$i]+="$_$j"!~/ABC|A.*C.*B|CAB/&&${$_.$&}[$i-1])%=$%=1e9+7for A..D;$x+=$$j[-1]}}print$x%$%

Measured memory_bytes: 1024
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
min_H = abs((T*1000 - (10**5+1)*6) - A*1000)
min_i = 0
for i in range(N):    
    if min_H > abs((T*1000 - H[i]*6) - A*1000):
        min_H = abs((T*1000 - H[i]*6) - A*1000)
        min_i = i
print(min_i+1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
import heapq
from collections import defaultdict


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    # for d in range(M): d日以内に終わる仕事で残っている最大のものを受ける
    L = [] # d日以内に終わる最大のしごと
    Q = defaultdict(list)
    for a, b in zip(A, B):
        heapq.heappush(Q[a], -b)
    
    res = 0
    for d in range(1, M+1):
        for b in Q[d]:
            heapq.heappush(L, b)
        if len(L) == 0:
            continue
        b = heapq.heappop(L)
        res -= b

    print(res)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N;
    cin >> N;
    vector<int> A;
    vector<int> B;
    int ans = 0;
    rep(i, N)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    rep(i, N)
    {
        int b;
        cin >> b;
        B.push_back(b);
    }
    rep(i, N)
    {
        if (A[i] > B[i])
        {
            ans -= A[i] - B[i];
        }
        else
        {
            ans += (B[i] - A[i]) / 2;
        }
    }
    if (ans < 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//http://blog.livedoor.jp/dgd17/archives/11821338.html
inline complex<double> Circumcenter(complex<double> a, complex<double> b, complex<double> c) {

	//辺
	double eAB = abs(b - a);
	double eBC = abs(c - b);
	double eCA = abs(a - c);

	//角度(余弦定理)
	double aCAB = acos((eCA*eCA + eAB*eAB - eBC*eBC) / (2 * eCA*eAB));
	double aABC = acos((eAB*eAB + eBC*eBC - eCA*eCA) / (2 * eAB*eBC));
	double aBCA = acos((eBC*eBC + eCA*eCA - eAB*eAB) / (2 * eBC*eCA));

	double A = sin(2 * aCAB);
	double B = sin(2 * aABC);
	double C = sin(2 * aBCA);

	//外心の位置ベクトル(ベクトルの面積比の公式)
	complex<double> ans;
	ans.real((A*a.real() + B*b.real() + C*c.real()) / (A + B + C));
	ans.imag((A*a.imag() + B*b.imag() + C*c.imag()) / (A + B + C));
	return(ans);
} 

inline double Circumradius(complex<double> a, complex<double> b, complex<double> c) {

	//辺
	double eAB = abs(b - a);
	double eBC = abs(c - b);
	double eCA = abs(a - c);

	//角度(余弦定理)
	double aCAB = acos((eCA*eCA + eAB*eAB - eBC*eBC) / (2 * eCA*eAB));

	//外接円の半径(正弦定理)
	double R = 0.5*eBC / sin(aCAB);

	return(R);

}

int main(void){
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  vector<complex<double>> c(N);
  for (int i = 0; i < N; i++){
    c[i].real(x[i]);
    c[i].imag(y[i]);
  }
  if (N == 2){
    cout << abs(c[0]-c[1])/2;
  } else {
    double minrad = 10000;
    complex<double> cc;
    double cr;
    //2点
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        cc.real((c[i].real()+c[j].real())/2);
        cc.imag((c[i].imag()+c[j].imag())/2);
        cr = abs(c[j]-c[i])/2;
        if (cr < minrad){
          bool flg = true;
          for (int n = 0; n < N; n++){
            if (abs(cc - c[n]) > cr + 1e-7) flg = false;
          }
          if (flg) minrad = cr;
        }
      }
    }   
    //3点
    for (int i = 0; i < N; i++){
      for (int j = i + 1; j < N; j++){
        for (int k = j + 1; k < N; k++){
          cc = Circumcenter(c[i],c[j],c[k]);
          cr = Circumradius(c[i],c[j],c[k]);
          if (cr < minrad){
            bool flg = true;
            for (int n = 0; n < N; n++){
              if (abs(cc - c[n]) > cr + 1e-7) flg = false;
            }
            if (flg) minrad = cr;
          }
        }
      }
    }
    cout << minrad;
  }
}

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

const int MAXN = 105;

int N, X, L[MAXN];
int main(){
    scanf("%d %d", &N, &X);

    for(int i = 0; i < N; i++)
        scanf("%d", &L[i]);

    int r = 0, d = 0;
    for(int i = 0; i < N; i++){
        if(d <= X){
            d += L[i];
            r++;
        }else break;
    }
    if(d <= X)r++;
    printf("%d\n", r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

//b以上のスコアとなる手の握り方
ll num(ll b, vec &a){
    ll res = 0;
    rep(i,N){
        res += a.end() - lower_bound(ALL(a), b - a[i]);
    }
    return res;
}

ll sum(ll b, vec &a){
    vec s(N + 1, 0);
    Rrep(i,N) s[i] = s[i+1] + a[i];
    ll res = 0;
    rep(i,N){
        auto ite = lower_bound(ALL(a), b - a[i]);
        res += s[ite - a.begin()] + a[i] * (a.end() - ite);
    }
    return res;
}

int main(){
    cin>>N>>M;
    vec a(N);
    rep(i,N) cin>>a[i];
    sort(ALL(a));
    ll lb = 0, ub = 2e+5 + 1;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2;
        (num(cen, a) >= M ? lb : ub) = cen;
    }
    cout<<sum(lb + 1, a) + lb * (M - num(lb + 1, a))<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	string s;

	cin >> s;
	if (s.back() == 's') {
		s.push_back('e');
		s.push_back('s');
	}
	else {
		s.push_back('s');
	}
	cout << s << "\n";
	return 0;
}

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

using namespace std;

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

	int n,t;
	vector <int> v;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	int res = 1e9;

	for(int i=0;i<n;i++)
	{
		int sum1 = 0;
		int sum2 = 0;
		for(int j=0;j<n;j++)
		{
			if(j<=i)
			{
				sum1 += v[j];
			}
			else
			{
				sum2 += v[j];
			}
		}
		res = min(res,abs(sum1 - sum2));
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){

  long long int x1, y1, x2, y2;
  scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
  
  long long int x3, y3, x4, y4;
  
  x3 = x2 + (y1-y2);
  y3 = y2 + (x2-x1);
  x4 = x1 + (y1-y2);
  y4 = y1 + (x2-x1);
  
  std::cerr << "Answer: " << std::endl;
  std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {

    auto upd = [](pii &a, int x) {
        if (x > a.second) {
            a.second = x;
            if (a.first < a.second)swap(a.first, a.second);
        }
    };

    int N;
    scanf("%d", &N);
    int M = 1 << N;
    vi A(M);
    rep(i, M) scanf("%d", &A[i]);
    int re = 0;
    FOR(S, 1, M) {
        pii ma(0, 0);
        int T = S;
        do {
            upd(ma, A[T]);
            T = (T - 1)&S;
        } while (S != T);
        smax(re, ma.first + ma.second);
        printf("%d\n", re);
    }
}

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

using namespace std;

void DrawRect(int h, int w) {
	for( int i=0; i<h; i++ ) {
		string s = "";
		for( int j=0; j<w; j++ ) {
			s += "#";
		}
		cout << s << endl;
	}
}

int main() {
	int h,w;
	while( true ) {
		cin >> h >> w;
		if( h == 0 && w == 0 ) break;
		DrawRect( h, w );
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, m;
    cin >> n >> m;
    cout << mod_pow(n, m, mod) << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using sc = set<char>;
using vi = vector<int>;

int main () {

  int n; cin >> n; vi res; int ans = 0;
  while (n--) {
    int a; cin >> a;
    res.push_back(a);
  }
  for (size_t i = 1; i <= res.size(); i++) {
    if (res[i] < res[i - 1] && res[i] > res[i + 1] && i != res.size() - 1) {
      ans++;
    }
    else if (res[i] > res[i - 1] && res[i] < res[i + 1]) {
      ans++;
    }
    if (i == res.size() - 1) break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , x , y , ans ;

int hr[N] , parr[N] ;
int hb[N] , parb[N] ;

bool spec[N] ;

vector <int> gr[N] , gb[N] ;

void dfs (int v , vector <int> g[N] , int h[N] , int par[N]) {
	for (int u : g[v])
		if (u != par[v]) {
			par[u] = v ;
			h[u] = h[v] + 1 ;
			dfs(u , g , h , par) ;
		}
}

inline bool ok (int u , int v) {
	if (hb[u] > hb[v]) swap(u , v) ;

	if (hb[v] - hb[u] > 2) return 0 ;
	if (hb[v] - hb[u] == 2) return parb[parb[v]] == u ;
	if (hb[v] - hb[u] == 1) return parb[v] == u ;
	return parb[v] == parb[u] ;
}

void dfs_calc (int v) {
	if (hb[v] <= hr[v]) return ;

	if (spec[v]) {
		cout << "-1\n" ;
		exit(0) ;
	}
	ans = max(ans , 2 * hb[v]) ;

	for (int u : gr[v])
		if (u != parr[v]) dfs_calc(u) ;
}

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

	cin >> n >> x >> y ;
	x -- , y -- ;

	for (int i = 0 ; i < 2 * n - 2 ; i ++) {
		int u , v ;
		cin >> u >> v ;
		u -- , v -- ;
		(i < n - 1 ? gr : gb)[u].push_back(v) ;
		(i < n - 1 ? gr : gb)[v].push_back(u) ;
	}

	memset(parr , -1 , sizeof parr) ;
	dfs(x , gr , hr , parr) ;
	memset(parb , -1 , sizeof parb) ;
	dfs(y , gb , hb , parb) ;

	for (int v = 0 ; v < n ; v ++)
		for (int u : gr[v])
			if (!ok(u , v)) spec[u] = 1 ;

	dfs_calc(x) ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 39676
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

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



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

    int    n;
    string s, t;
    cin >> n;
    cin >> s;
    cin >> t;

    rep(i, n) {
        cout << s.at(i) << t.at(i);
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int euler_phi(int n){
	int res = n;
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0){
			res = res / i * (i - 1);
			while(n % i == 0) n /= i;
		}
	}
	if(n != 1) res = res / n * (n - 1);
	return res;
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", euler_phi(n));
	return 0;
}

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

int dp[5005][5005];

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  for(int i=n-1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(s[i]==s[j]) dp[i][j] = dp[i+1][j+1] + 1;
      else dp[i][j] = 0;
    }
  }
  
  int ans = 0;
  int p = 0;
  rep(i,n){
    rep(j,n){
      if(i>=j) continue;
      p = min(dp[i][j],j-i);
      ans = max(ans,p);
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 98048
// B. 

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	string s, ans;
	cin >> s;
	for (char c : s) {
		if (c == 'B') {
			if (!ans.empty()) {
				ans = ans.substr(0, ans.length() - 1);
			}
		} else {
			ans += c;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    S = lines.pop(0)
    RS = S[::-1]
    S = 'x' + S
    RS = 'x' + RS
    slist = []
    rslist = []
    ss = 0
    rss = 0
    for i in range(N):
        if S[i] == 'W':
            ss += 1
        if RS[i] == 'E':
            rss += 1
        slist.append(ss)
        #rslist.insert(0,rss)
        rslist.append(rss)
    #print(S)
    #print(RS)
    #print(list( zip(slist, rslist)))
    rslist.reverse()
    print(min([s + r for s, r in zip(slist, rslist)]))

#
# main
#
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

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

#define ll long long
#define oo 1e17
#define int long long

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , W;
int w[N] , v[N];
int dp[N][VAL];

/// dp[i][j] là trọng lượng tối thiếu để với i cái ba lô đầu có thể lấy được các vật có tổng = j.

main()
{
    //freopen("D.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >>  n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    dp[0][0] = 0;
    FOR(i , 1 , 1e5)
        dp[0][i] = 1e9 + 7;
    FOR(i , 1 , n)
    {
        FOR(j , 1 , 1e5)
        {
            dp[i][j] = dp[i - 1][j];
            if(j - v[i] >= 0)
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i] , dp[i][j]);
        }
    }
    FORD(i , 1e5 , 0)
        if(dp[n][i] <= W)
        {
            cout << i;
            exit(0);
        }
}


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

int main() {
    int N;
    cin >> N;
    int X[N];
    vector<int> s(N);
    rep(i,N){ cin >> X[i]; s[i] = X[i]; }
    sort(s.begin(),s.end());
    int r = s[N/2], l = s[N/2-1];
    if(r == l) {
        while(N--) cout << r << endl;
    }
    else {
        for(int i=0;i<N;++i) {
            if(X[i] > l) {
                cout << l << endl;
            }
            else cout << r << endl;
        }
    }

}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long long n, a;
    cin >> n;
    if (n <= 4 && n != 3) {
        cout << 4 << endl;
        return 0;
    }
    for (int i = 0; i < 100000; i++) {
        if (n % 2 == 0) {
            n = n / 2;
        } else {
            n = 3 * n + 1;
        }
        //    cout << n << " " << i << endl;
        if (n == 4) {
            cout << i + 5 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.B
{
    public class Program
    {
        public static int N { get; private set; }
        public static int K { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            K = inputs[1];

            var digits = 0;
            while (N >= Math.Pow(K, digits))
            {
                digits++;
            }

            return digits;
        }
    }
}


Measured memory_bytes: 11348
def commen_divisor(n,m): 
    i = 1
    table = []
    while i  <= max(n,m):
        if n%i == 0 and m%i==0:
            table.append(i)
        i += 1
    table = list(set(table))
    return sorted(table,reverse=True)

n,m,k=map(int,input().split())
print(commen_divisor(n,m)[k-1])

Measured memory_bytes: 3060
loop do
  s = gets.chomp
  break if s == '.'
  loop do
    slen = s.length
    s.gsub!(/\[([^\(\)\[\]])*\]/, '')
    s.gsub!(/\(([^\(\)\[\]])*\)/, '')
    break if slen == s.length
  end
  if ['(', ')', '[', ']'].any?{ |c| s.include?(c) }
    puts 'no'
  else puts 'yes'
  end
end

Measured memory_bytes: 10192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();

			int cnt = Integer.parseInt(line);

			double result = 0.0;
			for (int i = 0; i < cnt; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				if (tmp[1].equals("BTC")) {
					result += Double.parseDouble(tmp[0]) * 380000.0;
				} else {
					result += Double.parseDouble(tmp[0]);
				}

			}

			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    string s, t;
    cin >> s >> t;

    int cnt = 0;
    rep(i, s.length()) {
        if (s[i] != t[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;


    return 0;
}



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


int main() {
string S;
  cin >> S;
  if(S=="SUN")cout << 7 << endl;
  if(S=="MON")cout << 6 << endl;
  if(S=="TUE")cout << 5 << endl;
  if(S=="WED")cout << 4 << endl;
  if(S=="THU")cout << 3 << endl;
  if(S=="FRI")cout << 2 << endl;
  if(S=="SAT")cout << 1 << endl;
}

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

int main(){
  int N ;
  cin >> N ;
  vector<int> A(110) ;
  
  for(int i = 0 ; i < N ; i++){
    cin >> A[i] ;
  }
  sort(A.begin(),A.end()) ;
  reverse(A.begin(),A.end()) ;
  int totalA = 0 ;
  int totalB = 0 ;
  for(int i = 0 ; i<N ; i += 2){

    totalA += A[i] ;
    totalB += A[i+1] ;
  }
  
 cout << totalA-totalB << endl;
  
}




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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

#define UP 1
#define LEFT 2
#define SLANT 3

string LCS(string a, string b)
{
  int t[a.size()+1][b.size()+1];
  int move[a.size()+1][b.size()+1];
  fill(&move[0][0], &move[a.size()][b.size()+1], 0);
  fill(&t[0][0], &t[0][b.size()+1], 0);
  for(int i=1; i<a.size()+1; i++){
    t[i][0] = 0;
  }
 
  for(int i=1; i<a.size()+1; i++){
    for(int j=1; j<b.size()+1; j++){
      if(a[i-1] == b[j-1]){
        t[i][j] = t[i-1][j-1] + 1;
        move[i][j] = SLANT;
      }
      else if(t[i-1][j] >= t[i][j-1]){
        t[i][j] = t[i-1][j];
        move[i][j] = UP;
      }
      else if(t[i-1][j] < t[i][j-1]){
        t[i][j] = t[i][j-1];
        move[i][j] = LEFT;
      }
    }
  }
 
  string result;
  int i = a.size(), j = b.size();
  while(i != 0 && j != 0){
    if(move[i][j] == SLANT){
      result += a[i-1];
      i--;
      j--;
    }
    else if(move[i][j] == UP)
      i--;
    else if(move[i][j] == LEFT)
      j--;
  }
  reverse(result.begin(), result.end());
  return result;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<string> v(n);
    cin >> v;
    for (int i = 0; i < v.size(); ++i) {
      string s = v[i];
      sort(s.begin(), s.end());
      v[i] = s;
    }

    string s = v[0];
    for (int i = 1; i < v.size(); ++i) {
      s = LCS(s, v[i]);
    }
    cout << s << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int s,w; cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    int cou=0,ans=0;
    rep(i,n)std::cin >> a[i];
    rep(i,n-1){
        if(a[i]>=a[i+1]){
            cou++;
            ans=max(cou,ans);
        }
            
        else{
            cou=0;
        }
    }
    std::cout << ans << std::endl;
}

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

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

using namespace std;


int main()
{
	int n;
	cin>>n;
	
	bool adj[n+10][n+10]={};
	
	for(int i=1;i<n+1;++i){//1index
		
		int u;
		int k;
		cin>>u>>k;
		
		for(int j=1;j<k+1;++j){//1index
			int v;
			cin>>v;
			adj[i][v]=true;
		}
	}
	
	int d[n+10];
	for(int i=1;i<n+1;++i){
		d[i]=-1;
	}
	
	d[1]=0;
	
	queue<int> que;
	que.push(1);
	while(!que.empty()){
		int now=que.front();
		que.pop();
		
		int a=d[now];
		
		for(int j=1;j<n+1;++j){
			
			if((adj[now][j]) and (d[j]==-1)){
				d[j]=a+1;
			que.push(j);
			
			}
			
		}
	}
	
	for(int i=1;i<n+1;++i){
		cout<<i<<" "<<d[i]<<endl;
	}
	
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int cnt[N], m = N, M = 0;
    fill(cnt, cnt+N, 0);
    rep(i, N){
        int a; cin >> a;
        cnt[a]++;
        chmin(m, a), chmax(M, a);
    }
    if(M > m+1) cout << "No" << endl;
    elif(M == m){
        if(M > N/2 && M != N-1) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else{
        if(cnt[m] < M && M <= cnt[m]+cnt[M]/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 640
def lis(n):
    m=[]
    for i in range(len(n)):
        m.append(n[i])
    return(m)


a=input()
b=input()
ans=0
new_list=lis(a)
for k in range(len(a)):
    l=new_list.pop(-1)
    new_list.insert(0,l)
    if new_list==lis(b):
        ans=+1
if ans==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
N = gets.chomp.to_i

def dfs(s, bit)
  # N以上の七五三数は調べない
  if s.to_i > N
    return 0
  end
  if bit == 7
    ret = 1
  else
    ret = 0
  end
  ret += dfs(s + '3', bit | 1)
  ret += dfs(s + '5', bit | 2)
  ret += dfs(s + '7', bit | 4)
  return ret
end

print dfs('0', 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a,b,n;
 cin>>a>>b>>n;
  if(n<b){
    cout<<floor(a*n/b);
  }
  else{
    cout<<floor(a*(b-1)/b);
  } 
}


Measured memory_bytes: 3784
N = int(input())

divisor = set([N, N - 1])
x = N
for i in range(2, int(x ** 0.5) + 1):
    z = x
    while z % i == 0:
        z //= i
    if z % i == 1:
        divisor.add(i)
        
    if i == x // i:
        continue
        
    z = x
    while z % (x // i) == 0:
        z //= (x // i)
    if z % (x // i) == 1:
        divisor.add((x // i))
        
x = N - 1
for i in range(2, int(x ** 0.5) + 1):
    if x % i == 0:
        divisor.add(i)
        divisor.add(x // i)

print(len(divisor) if N > 2 else 1)


Measured memory_bytes: 41068
A, B, C, D = gets.split('').map(&:to_i)

8.times do |i|
    bits = sprintf("%03b", i).split('')
    sum = A
    sum += bits[0] == '0' ? B : -B
    sum += bits[1] == '0' ? C : -C
    sum += bits[2] == '0' ? D : -D
    if sum == 7
        print A
        print bits[0] == '0' ? '+' : '-'
        print B
        print bits[1] == '0' ? '+' : '-'
        print C
        print bits[2] == '0' ? '+' : '-'
        print D
        print '=7'
        exit
    end
end

Measured memory_bytes: 1788
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = scanner.nextInt();
            int M = scanner.nextInt();
            int[] a = new int[N];
            int[] b = new int[N];
            int[] c = new int[M];
            int[] d = new int[M];
            for (int i = 0; i < N; i++) {
                a[i] = scanner.nextInt();
                b[i] = scanner.nextInt();
            }
            for (int i = 0; i < M; i++) {
                c[i] = scanner.nextInt();
                d[i] = scanner.nextInt();
            }

            for (int i = 0; i < N; i++) {
                long min = Long.MAX_VALUE;
                int minIndex = 0;
                for (int j = 0; j < M; j++) {
                    long manhattan = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
                    if (manhattan < min) {
                        min = manhattan;
                        minIndex = j;
                    }
                }
                System.out.println(minIndex + 1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


bool judge(Wint &A){
  const int n = A.size();
  REP(i, n-1){
    int diff = A[i+1][0] - A[i][0];
    FOR(j, 1, n) if(diff != A[i+1][j] - A[i][j]) return false;
  }
  REP(j, n-1){
    int diff = A[0][j+1] - A[0][j];
    FOR(i, 1, n) if(diff != A[i][j+1] - A[i][j]) return false;
  }
  return true;
}

int main(void){
  Wint A(3, Vint(3));
  REP(i, 3) REP(j, 3) cin >> A[i][j];
  cout << (judge(A)? "Yes" : "No") << BR;
  return 0;
}

Measured memory_bytes: 888
def LI():
	return [ int(s) for s in input().split() ]
D,G = LI()

problems = [LI() for _ in range(D)]

cnt_pnum = 0
cnt_score = 0
min_pnum = 10000000

for i in range(2**D):
  bonus = []
  cnt_pnum = 0
  cnt_score = 0
  for j in range(D):
    if i >> j & 1:
      bonus.append(j)
      cnt_score+=100*(j+1)*problems[j][0] + problems[j][1]
      cnt_pnum += problems[j][0]
      
  for j in reversed(range(D)):
    if not (i >> j & 1):
      for k in range(problems[j][0]):
        if cnt_score >= G:
          break
        cnt_score+=100*(j+1)
        cnt_pnum += 1
    if cnt_score >= G:
      if cnt_pnum < min_pnum:
      	min_pnum = cnt_pnum
      break
    
print(min_pnum)




Measured memory_bytes: 3064
import math
a, b, k = list(map(int, input().split(' ')))
if k > a*a*b / 2:
    # k = a*a*b - a*a*p/2 | pは斜めの水の内側の高さの方の辺, p = b で丁度半分
    # p = 2b - 2k/(a*a)
    p = 2*b - 2*k / (a*a)
    # 三角形の長い方をqとして qq = pp + aa
    q = (p**2 +a**2) ** 0.5
    
    # q * sin(r) = p
    # r = ... わからんので 2分探索
    left = 0.0
    right = 90.0
    while right > left + 1e-12:
        r = (left + right) / 2.0
        if q * math.sin(math.radians(r)) < p:
            left = r
        else:
            right = r
else:
    # k = a*b*p/2
    # p = 2*k/(a*a)
    p = 2*k/(a*b)
    # 三角形の長い方をqとして qq = pp + aa
    q = (p**2 +b**2) ** 0.5
    # r = ... わからんので 2分探索
    left = 0.0
    right = 90.0
    while right > left + 1e-12:
        r = (left + right) / 2.0
        if q * math.sin(math.radians(r)) < b:
            left = r
        else:
            right = r
print(r)

Measured memory_bytes: 3188