akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double x,y;
		y=(a*f-d*c)/(a*e-b*d);
		x=(c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

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

using namespace std;

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

  int t1 = 0, t2=0;
  for (int i = 0; i < n; i++) {
    int y1 = sum/n;
    int y2 = (sum+n-1)/n;
    t1 += (a[i]-y1) * (a[i]-y1);
    t2 += (a[i]-y2) * (a[i]-y2);
  }
  cout << min(t1, t2) << endl;

  return 0;
}


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

using namespace std;
int main(){
  long X,A,B;
  cin >>X >>A >>B;
  if(A+X<B)
    cout <<"dangerous"<<endl;
  else if(A<B)
    cout <<"safe"<<endl;
  else
    cout <<"delicious"<<endl;
  return 0;
}


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

using namespace std;

double max(double a,double b){
	if(a>=b)return a;
	else return b;
}

double min(double a,double b){
	if(a>=b)return b;
	else return a;
}

class polygon_obj{

public:
	int m;
	double x[10];
	double y[10];

	double maxX,minX,maxY,minY;
};

int main(){

	int n;

	polygon_obj poly[51];

	while(cin>>n){
		if(n==0)break;
		set<int> ans;

		for(int i=0;i<=n;i++){
			poly[i].maxX=-50000;
			poly[i].minX=50000;
			poly[i].maxY=-50000;
			poly[i].minY=50000;
		}

		for(int i=0;i<=n;i++){
			int m;
			cin>>poly[i].m;
			for(int j=0;j<poly[i].m;j++){
				cin>>poly[i].x[j]>>poly[i].y[j];
				poly[i].maxX = max(poly[i].maxX,poly[i].x[j]);
				poly[i].minX = min(poly[i].minX,poly[i].x[j]);
				poly[i].maxY = max(poly[i].maxY,poly[i].y[j]);
				poly[i].minY = min(poly[i].minY,poly[i].y[j]);
			}

			//???????????????????????????????????????????????§?¨????????´¢???
			//??????????????§?¨????0,0??????????§????????????????
			double centerX=(poly[i].maxX+poly[i].minX)/2.0;
			double centerY=(poly[i].maxY+poly[i].minY)/2.0;

			for(int j=0;j<poly[i].m;j++){
				poly[i].x[j]-=centerX;
				poly[i].y[j]-=centerY;
			}
		}

		for(int i=0;i<4;i++){
			//90????????¢????????????
			
			for(int j=0;j<poly[i].m;j++){
				double tmpX = poly[0].x[j];
				double tmpY = poly[0].y[j];
				poly[0].x[j] = -tmpY;
				poly[0].y[j] = tmpX;
			//	cout<<poly[0].x[j]<<poly[0].y[j]<<endl;
			}

			//cout<<endl<<endl;



			//??????????????¨????´¢????????????
			for(int j=1;j<=n;j++){
				int ansFlag=0;
				if(poly[0].m!=poly[j].m){
					continue;
				}
				for(int k=0;k<poly[0].m;k++){
					if(poly[0].x[k]!=poly[j].x[k] || 
						poly[0].y[k]!=poly[j].y[k]){
						ansFlag=1;
						break;
					}
				}
				if(ansFlag==0){
					ans.insert(j);
					continue;
				}
				ansFlag=0;
				for(int k=0;k<poly[0].m;k++){
					if(poly[0].x[poly[0].m-k-1]!=poly[j].x[k] || 
						poly[0].y[poly[0].m-k-1]!=poly[j].y[k]){
						ansFlag=1;
						break;
					}
				}
				if(ansFlag==0){
					ans.insert(j);
					continue;
				}
			}

		}

		//cout<<"UNKO"<<endl;
		for(set<int>::iterator it = ans.begin();it!=ans.end();it++){
			cout<<*it<<endl;
		}
		cout<<"+++++"<<endl;


	}
	return 0;

}

Measured memory_bytes: 1240
//
//  main.cpp
//  atcoder-slimes
//
//  Created by r on 6/1/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

long long N;
long long a[410];
long long pref[410];
long long dp[410][410];

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (long long i = 0; i<N; i++) {
        cin >> a[i];
    }
    long long curr = 0;
    for (long long i = 1; i<=N; i++) {
        curr+=a[i-1];
        pref[i] = curr;
    }
    for (long long i = N-1; i>=0; i--) {
        for (long long j = i+1; j<N; j++) {
            dp[i][j] = numeric_limits<long long>::max();
            for (long long k = i+1; k<=j; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k-1]+dp[k][j]+pref[j+1]-pref[i]);
            }
        }
    }
    cout << dp[0][N-1] << endl;
    return 0;
}





Measured memory_bytes: 1664
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String c = sc.next();
		char[] sChar = new char[3];
		char[] cChar = new char[3];
		int count = 0;
		for(int i = 0; i < 3; i++){
			sChar[i] = s.charAt(i);
			cChar[i] = c.charAt(i);
			if(sChar[i] == cChar[i]){
				count++;
			}
		}
		System.out.println(count);
	}
 
}

Measured memory_bytes: 21844
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
vector<int>adj[MAX];
int arr[MAX];
int vis[MAX];
void dfs(int a){
	vis[a]=1;
	for(int i=0;i<adj[a].size();i++){
		if(!vis[adj[a][i]]){
			arr[adj[a][i]]+=arr[a];
			dfs(adj[a][i]);
		}
	}
}
int main(){
	int cnt=0;
	long long a, b;
	cin>>a>>b;
	long long g=__gcd(a, b);
	for(long long i=2;i*i<=g;i++){
		long long d=i;
		if(g%d==0){
			cnt++;
			while(g%d==0)
				g=g/d;
		}
	}
	if(g>1)
		cnt++;
	cnt++;
	cout<<cnt;

}

Measured memory_bytes: 2560
n = int(input())
s = list(input())
cum_s = []
wum = 0
eum = 0
for i in range(n):
    if s[i] == "W":
        wum += 1
    else:
        eum += 1
    cum_s.append([wum,eum])
r = cum_s[-1]
ans = int(1e10)
for i in range(n):
    tar = cum_s[i]
    cnt = 0
    if s[i] == "W":
        cnt += tar[0]-1
        cnt += r[1] - tar[1]
    else:
        cnt += tar[0]
        cnt += r[1] - tar[1]
    ans = min(ans,cnt)
print(ans)




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

public class Main {

	void submit() {
		char[] s = nextToken().toCharArray();
		int n = s.length;

		long ans = 1;
		
		int[] cnt = new int[26];
		for (int i = 0; i < n; i++) {
			int c = s[i] - 'a';
			cnt[c]++;
			
			ans += (i + 1 - cnt[c]);
		}
		out.println(ans);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


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

int main() {
  int N;
  char S;
  string ans = "Three";
  
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> S;
    if(S == 'Y'){
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define SWAP(type,a,b)do{type temp=a;a=b;b=temp;}while(0)
typedef struct{
  char name[5];
  int many;
}P;
int main(){
  int i,j,n,b,cnt[5],flg,c;
  char nametmp[5];
  scanf("%d",&n);
  P a[5][n];
  for(i=0;i<5;i++)cnt[i]=0;

  for(i=0;i<n;i++){
    scanf("%s %d",nametmp,&b);
    c=strlen(nametmp)-1;
    for(j=0,flg=0;j<cnt[c];j++){
      if(strcmp(nametmp,a[c][j].name)==0){
	a[c][j].many+=b;
	flg=1;
	break;
      }
    }
    if(flg==0){
      strcpy(a[c][cnt[c]].name,nametmp);
      a[c][cnt[c]].many=b;
      cnt[c]++;
    }
  }
  for(c=0;c<5;c++){
    for(i=0;i<cnt[c]-1;i++){
      for(j=cnt[c]-1;j>i;j--){
	if(strcmp(a[c][j].name,a[c][j-1].name)<0){
	  SWAP(P,a[c][j],a[c][j-1]);
	}
      }
    }
  }
  for(c=0;c<5;c++){
    for(j=0;j<cnt[c];j++){
      printf("%s %d\n",a[c][j].name,a[c][j].many);
    }
  }
  return 0;
}

Measured memory_bytes: 648
a, b , c, x , y = map(int, input().split())

ab_n = 2 * (max(x, y))
ans = float("inf")

for i in range(0, ab_n + 1, 2):
    a_n = x - i // 2
    b_n = y - i // 2
    if a_n < 0:
        a_n = 0
    if b_n < 0:
        b_n = 0
    ans = min(ans, a * a_n + b * b_n + c * i)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;

int main() {
	vector<vector<int>> sheet(3, vector<int>(3));
	rep(i, 3) {
		rep(j, 3) cin >> sheet.at(i).at(j);
	} 
	int N;
	cin >> N;
	vector<int> num(N);
	rep(i, N) cin >> num.at(i);

	rep(i, N) {
		rep(j, 3) {
			rep(k, 3) {
				if(sheet.at(j).at(k) == num.at(i)) sheet.at(j).at(k) = 0;
			}
		}
	}

	string ans = "No";
	rep(i, 3) {
		if(sheet.at(i).at(0) == 0 && sheet.at(i).at(1) == 0 && sheet.at(i).at(2) == 0) ans = "Yes";
	}
	rep(i, 3) {
		if(sheet.at(0).at(i) == 0 && sheet.at(1).at(i) == 0 && sheet.at(2).at(i) == 0) ans = "Yes";
	}
	if(sheet.at(0).at(0) == 0 && sheet.at(1).at(1) == 0 && sheet.at(2).at(2) == 0) ans = "Yes";
	if(sheet.at(0).at(2) == 0 && sheet.at(1).at(1) == 0 && sheet.at(2).at(0) == 0) ans = "Yes";

	cout << ans << endl;
 }

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,q; cin >> n >> q;
  string s; cin >> s;

  vector<lint> a(n);
  a[0] = 0;
  for(lint i=1;i<n;i++) {
    a[i] = a[i-1];
    if(s[i-1] == 'A' && s[i] == 'C') { a[i]++; }
    //cout << a[i] << endl;
  }

  vector<lint> ans(q);
  for(lint i=0;i<q;i++) {
    lint l,r; cin >> l >> r;
    ans[i] = a[r-1]-a[l-1];
  }

  for(lint i=0;i<q;i++) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 2688
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:usize = read::<String>().chars().filter(|&x| x == '2').count();
    println!("{}",n);
}

Measured memory_bytes: 4352
n = gets.chomp.to_i
array = []
count = 0
(1..n).each do |num1|
  (1..n).each do |num2|
    if num1 % num2 == 0
      count += 1
    end
  end
  if count == 8
    array.push(num1)
  end
  count = 0
end

ans = 0
array.each do |num3|
  if num3 % 2 == 1
    ans += 1
  end
end
puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
//https://codeforces.com/contest/1228/problems
//https://codeforces.com/contest/1228/submit
 #include<cstdio>
 #include<queue>
 #include<vector>
 using namespace std;
 const ll MAX_V=100000+5;
 const ll INF=1ll<<62;
 struct edge
 {
     ll to,cost;
 };
 typedef pair<ll,ll>P;//first是最短距离，second是顶点编号
 ll V,E;
 vector<edge>G[MAX_V];
 ll d[MAX_V];
 void dijstra(ll s)
 {
     //通过指定greater<P>参数，堆按照first从小到大的顺序取出值
     priority_queue<P,vector<P>,greater<P> >que;
     fill(d+1,d+V+1,INF);
     d[s]=0ll;
     que.push(P(0ll,s));
     while(!que.empty())
     {
         P p=que.top();
         que.pop();
         ll v=p.second;
         if(d[v]<p.first)
            continue;
         for(ll i=0ll;i<G[v].size();i++)
         {
             edge e=G[v][i];
             if(d[e.to]>d[v]+e.cost)
             {
                 d[e.to]=d[v]+e.cost;
                 que.push(P(d[e.to],e.to));
             }
         }
     }
 }
 int main()
 {
     scanf("%lld",&V);
     E = V-1ll;
     ll u,v,val;
     edge e;
     for(ll i=0ll;i<E;i++)
     {
         scanf("%lld%lld%lld",&u,&v,&val);
         e.to=v;
         e.cost=val;
         G[u].push_back(e);
         e.to=u;
         e.cost=val;
         G[v].push_back(e);
     }
     ll q,k;
     sld(q) sld(k)
     dijstra(k);
     ll a,b;
     for(ll i=1ll;i<=q;i++)
     {
         sld(a) sld(b)
         printf("%lld\n",d[a]+d[b]);
     }
     return 0;
 }


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  if (S.at(K-1) == 'A') {
    S.at(K-1) = 'a';
  }
  else if (S.at(K-1) == 'B') {
    S.at(K-1) = 'b';
  }
  else {
    S.at(K-1) = 'c';
  }
  cout << S << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  IOS
  // INTXT
  int n, a, b;
  cin >> n >> a >> b;
  
  cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int i=0;
  while(i>=0){
    if(a>=b){
      b*=2;
      i++;
    }else break;
  }
  	while(i<k){
      if(b>=c){
      c*=2;
      i++;
      }else if(b<c){
        
        break;
      }
    }
  if(a<b&&b<c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    

Measured memory_bytes: 3596
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// hi + hj == i - j  i >= j
 //  hj + j == i - hi 	
	map<int,int> cnt;
	int n;
	cin>>n;
	vi h(n);
	rep(i,0,n-1)cin>>h[i];
	ll ans = 0;
	rep(i,0,n-1){
		ans += cnt[i - h[i]];
		cnt[h[i]+i]++;	
	}
	cout<<ans<<nl;
	return 0;
}



Measured memory_bytes: 21148
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]ai=new int[n];
		int[]bi=new int[n];
		for(int i=0;i<n;i++) {
			ai[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			bi[i]=sc.nextInt();
		}
		long minusNums=0;
		long minusNumsLength=0;
		int[]plusNums=new int[n];
		for(int i=0;i<n;i++) {
			if(ai[i]-bi[i]<0) {
				minusNums+=ai[i]-bi[i];
				minusNumsLength++;
			}else {
				plusNums[i]=ai[i]-bi[i];
			}
		}
		if(minusNums==0) {
			System.out.println("0");
			return;
		}
		Arrays.sort(plusNums);
		for(int i=0;i<plusNums.length;i++) {
			minusNums+=plusNums[plusNums.length-i-1];
			if(minusNums>=0) {
				System.out.println(minusNumsLength+i+1);
				return;
			
			}
		}
		System.out.println("-1");
		
	}
}



Measured memory_bytes: 64928
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
int N;
bool so[55556];
std::vector<int> ans;
int main(){
    std::cin>>N;
    so[1]=true;
    for(int i=2;i<=55555;i++){
        if(!so[i]){
            int e=i+i;
            while(e<=55555){
                so[e]=true;
                e+=i;
            }
        }
    }
    for(int i=3;i<=55555;i+=10){
        if(!so[i])ans.push_back(i);
    }
    for(int i=0;i<N;i++){
        std::cout<<ans[i]<<(i<N-1?" ":"\n");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        //String str[]=br.readLine().split(" ");
        //int n=Integer.parseInt(br.readLine());
        //int n=Integer.parseInt(str[0]);
        //int n=Integer.parseInt(str[1]);
        String s=br.readLine();
        if(s.indexOf('7')!=-1)
        pw.println("Yes");
        else
        pw.println("No");
        pw.flush();
        pw.close();
    }
}

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

int main(){
  int a;
  cin >> a;
  
  long long int sum = 1;
  for(int i = 1; i <= a; i++){
	sum *= i;
    sum %= 1000000007;
  }
  
  long long int ans = sum % 1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int main()
{
    char ch;
    cin >> ch;
    if (ch >= 'a' and ch <= 'z')
    {
        cout << "a";
    }
    else
    {
        cout << "A";
    }
}

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

using namespace std;

const int MOD =(int) 1e9+7;
int modulo(long long a) {
    return (a%MOD+MOD)%MOD;
}
int mult(long long a, long long b) {
    long long res=(long long) modulo(a)*modulo(b)%MOD;
    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long product=1;
    if(a[n-1]==0 && k%2==1) {
        cout << 0 << endl;
        return;
    }
    if(a[n-1]<=0 && k%2==1) {
        for(int i=n-1; i>=n-k; i--)
            product=mult(product, a[i]);
        cout << product << endl;
        return;
    }
    int l=0, r=n-1;
    if(k%2==1) {
        product=mult(product, a[r]);
        r--;
        k--;
    }
    k>>=1;
    for (int it=0; it<k; it++) {
        long long left_product=a[l]*a[l+1];
        long long right_product=a[r]*a[r-1];
        if(left_product>right_product) {
            product=mult(product, left_product);
            l+=2;
        } else {
            product=mult(product, right_product);
            r-=2;
        }
    }
    cout << product << endl;
}

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

Measured memory_bytes: 4780
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
    exit()
if x<y:
    x,y=y,x
if 2*y<x:
    print(0)
    exit()
mod=10**9+7
a=(2*y-x)//3
b=(2*x-y)//3
mx=10**6
k=[1]*(mx+1)
def inv(n):
    return pow(n,mod-2,mod)
for i in range(mx):
    k[i+1]=k[i]*(i+1)%mod
ans=(k[a+b]*inv(k[a])*inv(k[b]))%mod
print(ans)

Measured memory_bytes: 48560
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer[] a = new Integer[n - 1];
        List<Integer> list = new ArrayList<Integer>();

        for (int i = 0; i < n - 1; i++) {
            list.add(Integer.parseInt(scanner.next()));
        }

        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (Integer temp : list) {
            Integer count = map.get(temp);
            map.put(temp, (count == null) ? 1 : count + 1);
        }

        Integer[] total = new Integer[n];
        Arrays.fill(total, 0);
        for (Integer nKey : map.keySet())
        {
            total[nKey-1] = map.get(nKey);
        }

        for(int i = 0; i < total.length; i++) {
            System.out.println(total[i]);
        }
    }
}

Measured memory_bytes: 65840
#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 int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

ll lcm(ll a, ll b) {
	ll c = (b / gcd(a, b));
	return c * a;
}

int N, M;
int A[100010], B[100010];
pair <int, int> p[100010];

int main() {
	cin >> N >> M;
	REP(i, N) {
		cin >> A[i] >> B[i];
		p[i].first = A[i], p[i].second = B[i];
	}
	sort(p, p + N);
	ll money = 0;
	int i = 0;
	int j = 0;
	while (M > j) {
		if (p[i].second > 0) {
			p[i].second--;
			money += p[i].first;
			j++;
		}
		else i++;
	}
	cout << money << endl;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct edge{int nx,t,w;}e[MN*2+5];
int n,h[MN+5],en,s[MN+5],mn=1e9,mp;
long long ans;
inline void ins(int x,int y,int w)
{
	e[++en]=(edge){h[x],y,w};h[x]=en;
	e[++en]=(edge){h[y],x,w};h[y]=en;
}
void dfs(int x,int fa)
{
	int i,mx=0;s[x]=1;
	for(i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		dfs(e[i].t,x);
		s[x]+=s[e[i].t];
		mx=max(mx,s[e[i].t]);
		if(s[e[i].t]*2==n)ans-=e[i].w;
		ans+=2LL*min(n-s[e[i].t],s[e[i].t])*e[i].w;
	}
	mx=max(mx,n-s[x]);
	if(mx<mn)mn=mx,mp=x;
}
int main()
{
	int i,x,y;
	for(n=read(),i=1;i<n;++i)x=read(),y=read(),ins(x,y,read());
	dfs(1,0);
	if(mn*2<n){for(mn=1e9,i=h[mp];i;i=e[i].nx)mn=min(mn,e[i].w);ans-=mn;}
	printf("%lld",ans);
}

Measured memory_bytes: 8576
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = gets.chomp.to_i
puts A[K-1]

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

void main() {
    auto N = readln.chomp.to!int;
    int E = 0;
    auto used = new bool[][](N, N);
    auto black = new string[](N);
    foreach (i; 0..N) black[i] = "0";
    string[] ans = ["!"];

    while (E < N - 1) {
        int a = uniform(0, N);
        int b = uniform(0, N);
        if (a == b) continue;
        if (used[a][b]) continue;

        black[a] = black[b] = "1";
        writeln("? " ~ black.join(""));
        stdout.flush;
        auto radius = readln.chomp.to!int;
        if (radius) ans ~= ("(" ~ a.to!string ~ "," ~ b.to!string ~ ")");
        E += radius;

        black[a] = black[b] = "0";
        used[a][b] = true;
        used[b][a] = true;
    }

    ans.join(" ").writeln;
    stdout.flush;

}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int d,t,s;
    cin >> d >> t >> s;
    int distance = s*t;
    if(distance >= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	char s[5];
	scanf("%s",s+1);
	int a=s[1]-'0',b=s[2]-'0',c=s[3]-'0',d=s[4]-'0';
	if (a+b+c+d==7) printf("%d+%d+%d+%d=%d\n",a,b,c,d,7);
	else if (a-b+c+d==7) printf("%d-%d+%d+%d=%d\n",a,b,c,d,7);
	else if (a+b-c+d==7) printf("%d+%d-%d+%d=%d\n",a,b,c,d,7);
	else if (a+b+c-d==7) printf("%d+%d+%d-%d=%d\n",a,b,c,d,7);
	else if (a-b+c-d==7) printf("%d-%d+%d-%d=%d\n",a,b,c,d,7);
	else if (a-b-c+d==7) printf("%d-%d-%d+%d=%d\n",a,b,c,d,7);
	else if (a+b-c-d==7) printf("%d+%d-%d-%d=%d\n",a,b,c,d,7);
	else if (a-b-c-d==7) printf("%d-%d-%d-%d=%d\n",a,b,c,d,7);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int cnt = 0;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i++){
            A[i] = sc.nextInt();
        }
        shellSort(A, n);
        System.out.println(cnt);
        for(int i : A){
            System.out.println(i);
        }
    }

    public static void insertionSort(int[] A, int n, int g){
        for(int i = g; i < n; i++){
            int v = A[i];
            int j = i - g;
            while(j >= 0 && A[j] > v){
                A[j + g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j + g] = v;
        }
    }

    public static void shellSort(int[] A, int n){
        int[] G = new int[15];
        int m = 0;
        for(int i = 1; i <= n; i = i * 3 + 1){
            G[m] = i;
            m++;
        }
        System.out.println(m);
        for(int i = m - 1; i >= 0; i--){
            System.out.print((i == m - 1 ? "" : " ") + G[i] + (i == 0 ? "\n" : ""));
        }
        for(int i = m - 1; i >= 0; i--){
            insertionSort(A, n, G[i]);
        }
    }
}



Measured memory_bytes: 298488
//Author: ZindagiMeBasAishHiChahiye
//WA/TLE
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ll          long long
#define N 1000005
// ll po(ll a,ll b,ll m){
// 	a%=m;
// 	if(b==0) return 1;
// 	if(b%2) return (a*(po((a*a)%m,b/2,m)%m)%m)%m;
// 	return po((a*a)%m,b/2,m)%m;
// }

// bool check(ll a,ll b,ll n){
// 	if(a<0||b<0) return false;
// 	if(a>=n||b>=n) return false;
// 	return true;
// }

void solve(){
	string s;
	cin>>s;
	ll x=0;
	for(auto i:s)
		x+=(i-'0');
	if(x%9) cout<<"No\n";
	else cout<<"Yes\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1,z=1;
	// cin>>TESTS;
	while(TESTS--){
		// time
		// cout<<"Case #"<<z<<": ";
		// z++;
		solve();
		time

	}
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

vector<vector<int> > G;
vector<ll> h;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,m;
  cin >> n >> m;
  h = vector<ll>(n);
  rep(i,n) cin >> h[i];
  G = vector<vector<int> >(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  int ans = 0;
  rep(i,n) {
    bool ok = true;
    for (auto to : G[i]) {
      if (h[i] <= h[to]) {
        ok = false; break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <stdio.h>

int main (void) {
	int a;
	int b;
	int c[100];
	int i;
	int j;
	int k;
	
	i = 0;
	while (scanf("%d%d", &a,&b) != EOF) {
		/*
		c[i] = a + b;
		i++;
		 */
		c[0] = a + b;
		k = 1;
		while ((c[0] / 10) != 0 ) {
			c[0] = c[0] / 10;
			k++;
		}
		printf("%d\n", k);
	}
	
	/*for (j = 0; j < i; j++) {
		k = 1;
		while ((c[j] / 10) != 0 ) {
			c[j] = c[j] / 10;
			k++;
		}
		printf("%d\n", k);
	}*/
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<queue>

using namespace std;

int d[310][310];
int v[310][310];
queue<int>q;

int main()
{
	int n;
	scanf("%d",&n);
	bool flag=0;
	for(int i=1;i<=n;++i)
	for(int j=1;j<=n;++j)
	scanf("%d",&d[i][j]);
	for(int k=1;k<=n;++k)
	for(int i=1;i<=n;++i)
	for(int j=1;j<=n;++j)
	{
		if(d[i][j]>d[i][k]+d[k][j])return !printf("-1");
		if((d[i][j]==d[i][k]+d[k][j])&&d[i][k]!=0&&d[i][j]!=0&&d[k][j]!=0)v[i][j]=v[j][i]=1;
	}
	long long ans=0;
	q.push(1);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=1;i<=n;++i)
		{
			if(v[u][i]||v[i][u])continue;
			if(d[u][i])
			{
				ans+=d[u][i];
				q.push(i);
				v[u][i]=v[i][u]=1;
			}
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    k = int(input())

    #output
    mod = 0
    # %%
    if k % 2 == 0:
        print(-1)
    else:
        for i in range(k):
            mod += 7*pow(10, i, k) % k
            mod %= k
            if mod == 0:
                print(i+1)
                exit()
        print(-1)
        
    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()


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

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

    vector<int> west_attention_from_left(n);
    vector<int> east_attention_from_right(n);

    for (int i=0;i<n;i++){
        if (i==0){
            if (s[i] == 'W'){
                west_attention_from_left[i] = 1;
            } else {
                west_attention_from_left[i] = 0;
            }
        } else {
            if (s[i] == 'W'){
                west_attention_from_left[i] = west_attention_from_left[i-1] + 1;
            }else {
                west_attention_from_left[i] = west_attention_from_left[i-1];
            }
        }
    }
    reverse(s.begin(), s.end());

    for (int i=0;i<n;i++){
        if (i==0){
            if (s[i] == 'E'){
                east_attention_from_right[i] = 1;
            } else {
                east_attention_from_right[i] = 0;
            }
        } else {
            if (s[i] == 'E'){
                east_attention_from_right[i] = east_attention_from_right[i-1] + 1;
            }else {
                east_attention_from_right[i] = east_attention_from_right[i-1];
            }
        }
    }

    vector<int> change_direction_number(n);
    for (int i=0;i<n;i++){
        if (i == 0){
            change_direction_number[i] = east_attention_from_right[n - 2];
        } else if (i == n - 1){
            change_direction_number[i] = west_attention_from_left[n - 2];
        } else {
            change_direction_number[i] = west_attention_from_left[i-1] + east_attention_from_right[n - i - 2];
        }
    }
    cout << *min_element(change_direction_number.begin(), change_direction_number.end()) << endl;
    return 0;
}




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

signed main() {
  int X, Y;
  cin >> X >> Y;
  
  int ans = 0;
  if( X == 1 ) ans += 300000;
  else if( X == 2 ) ans += 200000;
  else if( X == 3 ) ans += 100000;
  
  if( Y == 1 ) ans += 300000;
  else if( Y == 2 ) ans += 200000;
  else if( Y == 3 ) ans += 100000;
  
  if( X == 1 && Y == 1 ) ans += 400000;
  cout << ans << endl;
  
    
    
}


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


int main() {

    int n;
    cin >> n;
    set<int> s;
    rep(i, n) {
        int d; cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e8+8;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,b[3];
	cin>>n>>b[0]>>b[1]>>b[2];
	int arr[8];
	for(int i=0;i<n;++i)
		cin>>arr[i];
	sort(b,b+3);
	int ans = 1e9;
	string at;
	int aperm[3];
	do
	{
		for(int mask=0;mask<(1<<(2*n));++mask)
		{
			int cans = 0,c[3]={},acc=1,f=0;
			for(int i=0;i<n;++i)
			{
				if(mask/acc%4==3)
					;
				else if(mask/acc%4==0)
					c[0] += arr[i],cans += 10,f|=1;
				else if(mask/acc%4==1)
					c[1] += arr[i],cans += 10,f|=2;
				else if(mask/acc%4==2)
					c[2] += arr[i],cans += 10,f|=4;
				acc *= 4;
			}
			if(f!=7)
				continue;
			cans -= 30;
			cans += abs(b[0]-c[0])+abs(b[1]-c[1])+abs(b[2]-c[2]);
			ans = min(cans,ans);
		}
	}while(next_permutation(b,b+3));
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> s = new HashMap<>(N);
		long ans = 0;
		for (int i = 0; i < N; i++) {
			String input = sc.next();
			char[] c = input.toCharArray();
			Arrays.sort(c);
			String tmp = new String(c);
			if (s.containsKey(tmp)) {
				int v = s.get(tmp) + 1;
				ans += v;
				s.put(tmp, v);
			} else {
				s.put(tmp, 0);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 53044
A = [list(map(int, (input().split()))) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

chk = [[0]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            chk[i][j] = 1

ans = "No"
for i in range(3):
    if chk[i][0] == chk[i][1] == chk[i][2] == 1:
        ans = "Yes"
        break
    if chk[0][i] == chk[1][i] == chk[2][i] == 1:
        ans = "Yes"
        break
if chk[0][0] == chk[1][1] == chk[2][2] == 1:
    ans = "Yes"
elif chk[0][2] == chk[1][1] == chk[2][0] == 1:
    ans = "Yes"

print(ans)


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

int main() {
  vector<int> a(32);
  a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a.at(K-1) << endl;

}


Measured memory_bytes: 256
def insertion(N: int, S: str)->str:
    bra, ket = 0, 0
    for c in S:
        if c == '(':
            bra += 1
        else:  # c == ')'
            if bra > 0:  # ペアが作れる
                bra -= 1
            else:  # ペアが作れない。
                ket += 1

    ret = ('(' * ket) + S

    bra, ket = 0, 0
    for c in reversed(S):
        if c == ')':
            ket += 1
        else:  # c == '('
            if ket > 0:  # ペアが作れる
                ket -= 1
            else:  # ペアが作れない
                bra += 1

    ret = ret + (')' * bra)

    return ret


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = insertion(N, S)
    print(ans)


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// End of Template //



int main() {

    lint N;
    cin >> N;

    lint sc = ceil(sqrt(N));

    for (lint i = sc; i > 0; i--) {
        if (N % i == 0) {
            cou(N / i + i - 2), exit(0);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL __int128
#define ll long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PII pair<int, int>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max(a * c, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
	return 0;
}

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

    using Graph = vector<vector<int>>;
 
int main() {

    int N;
    cin>>N;


    vector<int>  a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }

    int sum=0;
    int length=1;
    for(int i=0;i<N-1;i++){
        if(a.at(i)==a.at(i+1)){
            length++;
        }
        else
        {
            sum+=length/2;
            length=1;
        }
        
        if(i==N-2){
            sum+=length/2;
            length=1;
        }
    }

    cout<<sum<<endl;

 	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << ((s1[SIZE(s1)-1] == s2[0] && s2[SIZE(s2)-1] == s3[0])?"YES":"NO") << endl;
    return 0;
}

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

int bitcount(int n)
{
  int r(0);
  for (int i = 0; i < 32; i++) {
    if (n == 0) break;
    if ((n & 1) != 0) r++;
    n >>= 1;
  }
  return r;
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> k(m);

  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    for (int j = 0; j < s; j++) {
      int b;
      cin >> b;
      k[i] |= 1 << (b - 1);
    }
  }

  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }

  int ans(0);
  for (int i = 0; i < (1 << n); i++) {
    bool f(true);
    for (int j = 0; j < m; j++) {
      if (bitcount(k[j] & i) % 2 != p[j]) {
        f = false;
        break;
      }
    }
    if (f) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
char d[N];
long double x[N],y[N];
int n;
long double f(long double t){
	long double xmax = -inf , xmin=inf , ymax= -inf , ymin= inf;
	for(int i=0;i<n;i++){
		if(d[i]=='L') xmin=min(xmin,x[i]-t) , xmax=max(xmax,x[i]-t);
		else if(d[i]=='R') xmin=min(xmin,x[i]+t),xmax=max(xmax,x[i]+t);
		else
			xmax=max(xmax,x[i]),xmin=min(xmin,x[i]);
	}
	for(int i=0;i<n;i++){
		if(d[i]=='D') ymin=min(ymin,y[i]-t) , ymax=max(ymax,y[i]-t);
		else if(d[i]=='U') ymin=min(ymin,y[i]+t),ymax=max(ymax,y[i]+t);
		else
			ymax=max(ymax,y[i]),ymin=min(ymin,y[i]);
	}
	return (xmax-xmin)*(ymax-ymin);

}
signed main(){
  fast;
  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>d[i];

  long double l = 0 , r = 1000000000,md1,md2;
  for(int j=1;j<=1000;j++){
  	  md1=l+(r-l)/3 , md2= l+(r-l)*2/3;
  	  if(f(md1)<=f(md2)) r=md2;
  	  else l = md1;
  }
  cout<<fixed<<setprecision(12)<<f(r)<<endl;
}
  


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, x, t; cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t << '\n';
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main ()
{
    int S,h,m,s,a;
    scanf("%d", &S);
    a=S;
    h=a/3600;
    a=a-(h*3600);
    m=a/60;
    a=a-(m*60);
    s=a/1;
    a=a-(s*1);
    printf("%d:%d:%d\n", h,m,s);

    return 0;
}



Measured memory_bytes: 2096
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b - a > 1){
            int k2 = k - (a - 1);
            if(k2 > 0){
                long t = a;
                for (int i = 0;i < k2 / 2;++i){
                    t += b - a;
                }
                if(k2 % 2 == 1)++t;
                System.out.println(t);
            }
            else System.out.println(k + 1);
        }
        else System.out.println(k + 1);
    }

}




Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    string S; 
    ull first_not1_idx=0;
    ull K;
    cin >> S >> K;

    for (int i=0; i<min((ull) S.size(), K); i++) {
        if (S[i] >= '2') {
            cout << S[i] << endl;
            return 0;
        }
    }

    cout << '1' << endl;
    return 0;

}


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

Measured memory_bytes: 596
tmp = input()
line = input().split(" ")
for i in range(len(line)):
  line[i] = int(line[i])
line.sort()
count = 0
for i in range(0, len(line) - 2):
  for j in range(1, len(line) - 1):
    if i > j or i == j:
      continue
    for k in range(2, len(line)):
      if j > k or j == k:
        continue
      if int(line[i]) != int(line[j]) and int(line[j]) != int(line[k]):
        if int(line[i]) + int(line[j]) > int(line[k]):
          count += 1
print(count)

Measured memory_bytes: 9212
import math

N, D = [int(i) for i in input().strip().split()]
X = [[0] * D] * N
for i in range(N):
  X[i] = [int(i) for i in input().strip().split()]

cnt = 0
for i in range(N-1):
  for j in range(i+1, N):
    A = X[i]
    B = X[j]
    AB = 0.0
    for a, b in zip(A, B):
      AB += (b - a)**2
    AB = math.sqrt(AB)
    if AB.is_integer():
      cnt += 1
print(cnt)


Measured memory_bytes: 3064