akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = 100;
const double pi = acos(-1);

int x[MAXN + 1], y[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    for(i = 1; i <= n; i++) {
        vector <double> ang;
        for(j = 1; j <= n; j++) {
            if(i != j) {
                ang.push_back(atan2(x[j] - x[i], y[j] - y[i]));
            }
        }
        sort(ang.begin(), ang.end());
        double mx = 0.0;
        for(int i = 1; i < ang.size(); i++) {
            mx = max(mx, ang[i] - ang[i - 1]);
        }
        mx = max(mx, ang[0] - ang.back() + 2 * pi);
        cout << fixed << setprecision(20) << max(0.0, (mx - pi) / (2.0 * pi)) << "\n";
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 512
x, y = map(int, input().split())

if x < y:
    if abs(x - y) > abs(-x - y):
        print(abs(-x - y) + 1)
    else:
        print(abs(x - y))
else:
    print(min(abs(-x - y) + 1, abs(x - y) + 2))

Measured memory_bytes: 3060
import Control.Applicative

main :: IO ()
main = do
   [a, b] <- map read . words <$> getLine
   [c, d] <- map read . words <$> getLine
   putStrLn $ show (solve a b c d)
   
solve :: Int -> Int -> Int -> Int -> Int
solve a b c d = a * b - c * b - d * a + c * d

Measured memory_bytes: 508
from itertools import permutations
from math import factorial

N = int(input())
P = int("".join(input().split()))
Q = int("".join(input().split()))

A = []
for perm in permutations(range(1, N+1), N):
    A.append(int("".join([str(n) for n in perm])))
a = A.index(P)
b = A.index(Q)
print(abs(a-b))


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll k;
  cin >> k;
  if(k%2 == 0){
    cout << -1 << endl;
    return 0;
  }
  
  ll n = 7%k;
  REP(i, k){
    if(n == 0){
      cout << i+1 << endl;
      return 0;
    }else{
      n = (n*10+7)%k;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

ll pathy(int level)
{
    return 1+2*(pow(2,level)-1);
}

ll buger(int level)
{
    if(level==0)
    {
        return 1;
    }
    return 1+4*(pow(2,level)-1);
}

int main()
{
    int n;
    ll x;
    ll ans=0;
    cin>>n>>x;
    int currentlevel=n;
    ll edge=buger(n);
    ll start=1;
    //cout<<edge<<endl;
    while(edge-start>0)
    {
        ll point=(edge+start)/2;
        if(x==point)
        {
            ans+=pathy(currentlevel-1)+1;
            cout<<ans;
            return 0;
        }
        if(x<point)
        {
            edge=point-1;
            start+=1;
        }
        else
        {
            ans+=pathy(currentlevel-1)+1;
            start=point+1;
            edge-=1;
        }
        currentlevel-=1;
        //cout<<ans<<endl;
    }
    if(edge<=x)ans++;
     
    cout<<ans;
    
    

}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
//#include "rail.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e16;
const long long MOD = 1e9+7;
const int MAX=200015;
vector<int> v1,v2;
ll a[1000005];
ll b[1000005];

int main(){
    int n;
    cin>>n;
    int l=1,r=n;
    cout<<0<<endl;
    fflush(stdout);
    string s;
    cin>>s;
    int b=0;
    if(s=="Male"){
        b=1;
    }
    W(l!=r){
        int mid=(l+r)/2;
        cout<<mid<<endl;
        fflush(stdout);
        cin>>s;
        bool bol=0;
        if(s=="Male"){
            bol=1;
        }
        if(mid%2==0){
            if(bol==b){l=mid+1;}
            else r=mid;
        }
        else{
            if(bol!=b)l=mid+1;
            else r=mid;
        }
    }
    cout<<l<<endl;
    fflush(stdout);
}


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

int n,m;
int x,y;

int main(){
    cin>>n>>m;
    vector<pair<int,int>> box(n);
    box[0]=make_pair(1,1);
    for(int i=1;i<n;i++){
        box[i]=make_pair(1,0);
    }

    int cnt=0;

    for(int i=0;i<m;i++){
        cin>>x>>y;
        x--;
        y--;
        if(box[x].second==1 && box[x].first==1){
            box[x].first=0;
            box[x].second=0;
            box[y].second=1;
            box[y].first++;
        }
        else if(box[x].second==1 && box[x].first>1){
            box[x].first--;
            box[y].first++;
            box[y].second=1;
        }
        else if(box[x].second==0){
            box[x].first--;
            box[y].first++;
        }
    }

    for(int i=0;i<n;i++){
        if(box[i].second!=0) {
            cnt++;
        }
    }

    cout<<cnt<<endl;

}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for(int i = 0 ; i < n ; i++ ){
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        Double s = (v[0] + v[1]) * 1.0;
        for(int i = 2 ; i < n ; i++ ){
            s = s + v[i] * Math.pow(2 , i - 1);
        }
        System.out.println(s * 1.0 / Math.pow(2 , n - 1));
    }
}

Measured memory_bytes: 35892
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  int N, Q;
  std::cin >> N >> Q;
  std::string s;
  std::cin >> s;
  std::vector<char> t(Q), d(Q);
  for (int i=0; i<Q; i++) {
    std::cin >> t[i] >> d[i];
  }
  int ng = 0;
  {
    int left = -1, right=N;
    while(right-left>1) {
      int mid = (right+left) / 2;
      int pos =  mid;
      int q = 0;
      while(q<Q && pos<N && pos>=0) {
        if (t[q]==s[pos]) {
          if(d[q]=='L') pos--;
          else pos++;
        }
        q++;
      }
      if (pos==N) {
        right = mid;
      } else {
        left = mid;
      }
    }
    ng += N-right;
  }
  {
    int left = -1, right = N;
    while(right-left>1) {
      int mid = (right+left) / 2;
      int pos =  mid;
      int q = 0;
      while(q<Q && pos>=0 && pos<N) {
        if (t[q]==s[pos]) {
          if(d[q]=='L') pos--;
          else pos++;
        }
        q++;
      }
      if (pos==-1) {
        left = mid;
      } else {
        right = mid;
      }
    }
    ng += right;
  }
  std::cout << N-ng << std::endl;
  return 0;
}


Measured memory_bytes: 3556
#include<iostream>
using namespace std ; 
int main () {
int a, b ; 
cin>>a>>b ; 
if(a<b)
cout<<"a < b"<<endl ; 
if(a>b)
cout<<"a > b"<<endl ; 
if(a==b) 
cout<<"a == b"<<endl ; 




return 0 ; 
}


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

long long n,m;

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>m;
	
	if(n%2==1)
	for(int i=0;i<m;i++){
		cout<<(i+1)<<" "<<n-1-i<<"\n";
	}
	else{
		
		int tmp=(n/2-1);
		
		for(int i=0;i<tmp;i+=2){
			cout<<1+i/2<<" "<<1+tmp-int(tmp%2==0)-i/2<<"\n";
			m--;
			if(m==0)break;
		}
		
		for(int i=1;i<tmp;i+=2){
			if(m==0)break;
			cout<<n-(i-1)/2<<" "<<n-(tmp-tmp%2)+(i-1)/2<<"\n";
			m--;
		}
	}

return 0;
}


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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;

  return 0;
}

Measured memory_bytes: 896
n=int(input())
s=input()

le=0
ri=s[1:n].count("E")

minmuki=min(s[0:n-1].count("W"),s[1:n].count("E"))

for i in range(1,n-1):
    if s[i-1]=="W" :
        le+=1
    if s[i]=="E" :
        ri-=1
    minmuki=min(minmuki,le+ri)

print(minmuki)


Measured memory_bytes: 3828
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let w: usize = read();
    const INF: i64 = std::i64::MAX / 3;
    let v_max: usize = 100100;
    // (weight, value)
    let mut vec: Vec<(i64, i64)> = vec![];
    for _ in 0..n {
        vec.push((read(), read()));
    }
    let mut dp: Vec<Vec<i64>> = vec![vec![INF; v_max + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..v_max {
            if j < vec[i].1 as usize {
                dp[i + 1][j] = dp[i][j];
                continue;
            }
            dp[i + 1][j] = std::cmp::min(dp[i][j - vec[i].1 as usize] + vec[i].0, dp[i][j])
        }
    }
    let mut max_val = 0;
    for v1 in dp {
        for (i, &v2) in v1.iter().enumerate() {
            if v2 <= w as i64 {
                max_val = std::cmp::max(max_val, i);
            }
        }
    }

    println!("{}", max_val);
}


Measured memory_bytes: 106748
n=int(input())
a_n=list(map(int,input().split()))
count=0
ans=0
for i in a_n:
  if i <0:
    count +=1

def fun():
  tmp_ans=0
  for i in a_n:
    if i<0:
      tmp_ans += -1*i
    else:
      tmp_ans += i
  return tmp_ans

if count%2==0:
  ans = fun()
else:
  tmp=abs(a_n[0])
  for i in a_n:
    if tmp > abs(i):
      tmp = abs(i)
  
  ans =fun()-2*tmp
print(ans)

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

int main()
{
    string as,bs,cs;
    cin>>as>>bs>>cs;
    vector<char>arr;
    vector<char>frr;
    vector<char>krr;

    for(int i=0;i<as.size();i++)
    {
        arr.push_back(as[i]);
    }
    reverse(arr.begin(),arr.end());

     for(int i=0;i<bs.size();i++)
    {
        frr.push_back(bs[i]);
    }
    reverse(frr.begin(),frr.end());

     for(int i=0;i<cs.size();i++)
    {
        krr.push_back(cs[i]);
    }
    reverse(krr.begin(),krr.end());

    int counter=0;

    while(1)
    {
        if(counter==0)
        {
            int len=arr.size();
            if(len==0)
            {
                cout<<"A"<<endl;
                return 0;
            }
            char c=arr[len-1];
            arr.pop_back();
            if(c=='a')counter=0;
            if(c=='b')counter=1;
            if(c=='c')counter=2;
        }
         if(counter==1)
        {
            int len=frr.size();
            if(len==0)
            {
                cout<<"B"<<endl;
                return 0;
            }
            char c=frr[len-1];
            frr.pop_back();
            if(c=='a')counter=0;
            if(c=='b')counter=1;
            if(c=='c')counter=2;
        }
         if(counter==2)
        {
            int len=krr.size();
            if(len==0)
            {
                cout<<"C"<<endl;
                return 0;
            }
            char c=krr[len-1];
            krr.pop_back();
            if(c=='a')counter=0;
            if(c=='b')counter=1;
            if(c=='c')counter=2;
        }
    }
}


Measured memory_bytes: 256
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort()
cnt = 0
for i in b:
    a_i = bisect.bisect_left(a,i)
    c_i = bisect.bisect_right(c,i)
    cnt += a_i * (n - c_i)
print(cnt)

Measured memory_bytes: 105032
using System;

class AOJ{
  static void Main(string[] args)
  {
    int d, h;
    int ans;
    string s;

    while ((s = Console.ReadLine()) != null){

      d = int.Parse(s);
      ans = 0;

      for (int i = 1; i < 600 / d; i++){
        h = (d * d * i * i);
        ans += d * h;
      }
      Console.WriteLine(ans);
    }
  }
}

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

int main()
{
	
	string str;
	cin>>str;
	if(str.length()==1 && str[0]=='?')
	{
		cout<<"D"<<endl;
		return 0;
	}
	if(str.length()==1 && str[0]!='?')
	{
		cout<<str<<endl;
		return 0;
	}
	for(long long i=0;i<str.length();i++)
	{
		if(i==0 && str[i]=='?')
		{
			if(str[i+1]=='P')
			{
				str[i]='D';
			}
			else if(str[i+1]=='D')
			{
				str[i]='P';
			}
			else
			{
				str[i]='P';	
			}
			continue;
		}
		if(i==str.length()-1 && str[i]=='?')
		{
			str[i]='D';
			continue;
		}
		if(str[i]=='?')
		{
			if(str[i-1]=='P')
			{
				str[i]='D';
			}
			else if(str[i-1]=='D' && str[i+1]=='D')
			{
				str[i]='P';
			}
			else if(str[i-1]=='D' && str[i+1]=='P')
			{
				str[i]='D';
			}
			else
			{
				str[i]='P';
			}
		}
	}

	cout<<str<<endl;
	return 0;
	
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
using namespace std;
int main(void) {
    int k;
    string s;
    cin >> k;
    cin >> s;
    if (s.length() <= k) {
        cout << s << endl;
        return 0;
    }
    cout << s.substr(0, k) << "...\n";
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define float long double
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
  	int y , m , d;
  	cin >> y >> m >> d;
  	cout << y*m/2;
    return 0;
}


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

int a[20];
int m[200];
int n, q;


bool isSumOk(int sum,int m,int i) 
{
	if (i == n - 1) {
		if (sum == m) {
			return true;
		}
		else {
			return false;
		}
	}
	i++;
	bool pt = isSumOk(sum+a[i],m,i);
	bool pf = isSumOk(sum, m, i);

	return (pt || pf);
}


int main(void)
{

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

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

	for (int i = 0; i < q; i++) {
		cout << ((isSumOk(a[0], m[i], 0)||isSumOk(0,m[i],0)) ? "yes" : "no") << endl;
	}

	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

bool check(string S, int length){
    rep(i,length){
        if(S[i] != S[length-1-i]) return false;
    }
    return true;
}

int main(){
    string S;
    cin>>S;
    int N = S.size();
    int hoge = (N-1)/2;
    int nya = (N+3)/2;
    // cout<<S<<endl;
    // cout<<S.substr(0,hoge)<<endl;
    // cout<<S.substr(nya-1,N-nya+1)<<endl;
    if(check(S,N) & check(S.substr(0,hoge),hoge) & check(S.substr(nya-1,N-nya+1),N-nya+1)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n;
    cin>>n;
	cout<<n*(n-1)/2<<endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int AB = A * B;
  int X = AB / 2;
  int Y = (AB + 1) / 2;
  if (X == Y) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main()
{
  long double a,b,c;
  cin >>a >>b>>c;
  if((sqrt(a)+sqrt(b)+1.0E-14)<sqrt(c)){
      cout << "Yes";
  }else{
      cout << "No";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
 
int main(){
	ll n,m;
	cin>>n>>m;
	if(n>=10) cout<<m<<endl;
	else cout<<100*(10-n)+m<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int t;
  scanf("%d",&t);
  double mx=0;
  for(i=0;i<=t;++i){
    int n,m;
    scanf("%d%d",&n,&m);
    int v[100];
    double r[100],sm=0;
    for(j=0;j<m;++j){
      scanf("%d%lf",v+j,r+j);
      sm+=r[j];
    }
    double su=0;
    for(j=0;j<m;++j)
      su+=v[j]*r[j]/sm;
    if(i==t)
      puts(mx-su>0.0000001?"YES":"NO");
    mx=max(mx,su);
  }
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    for (int i = k; i < n; i++){
        if (a[i - k] < a[i]) puts("Yes");
        else
            puts("No");
    }
}


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

using namespace std;

int main() {
  long long x, y, z;
  cin >> x >> y >> z;
  auto ints = {x, y, z};
  if (any_of(ints.begin(), ints.end(), [](long long i){return i % 2 == 0;})) {
    cout << 0 << endl;
    return 0;
  }
  cout << min({x * y, y * z, x * z}) << endl;
  return 0;
}


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

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i) >> B.at(i);
    }

    vector<int> dp(H + 1);
    dp.at(0) = 0;
    for (int h = 1; h <= H; h++)
    {
        dp.at(h) = INT_MAX;
        for (int i = 0; i < N; i++)
        {
            int Ai = A.at(i);
            int Bi = B.at(i);
            int prev_h = max(0, h - Ai);
            dp.at(h) = min(dp.at(h), dp.at(prev_h) + Bi);
        }
    }
    cout << dp.at(H) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        if(dfs(i+1,a[i],right)) return true;
    }
    if(a[i]>right){
        if(dfs(i+1,left,a[i])) return true;
    }
    return false;
}
 
void solve(){
    for(int i=0;i<10;i++) cin >> a[i];
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return;
}
 
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1152
n=int(input())
a=list(map(int,input().split()))
sum_=[a[0]]
num=a[0]
for i in range(1,n):
    num=num+a[i]
    sum_.append(num)
count={}
for i in range(n):
    if sum_[i] in count:
        count[sum_[i]]+=1
    else:
        count[sum_[i]]=1
ans=0
for i in count.values():
    ans+=i*(i-1)//2
if 0 in count:
    ans+=count[0]
print(ans)

Measured memory_bytes: 113428
package main

import (
	"fmt"
)

func main() {

	var num int
	fmt.Scan(&num)
	var primeNum bool
	for {
		primeNum = checkPrimeNum(num)
		if primeNum {
			fmt.Println(num)
			break
		}
		num++
	}
}

func checkPrimeNum(num int) bool {
	primeNum := true
	for i := 2; i < num; i++ {
		if num%i == 0 {
			primeNum = false
			break
		}
	}

	return primeNum
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

long burger_size(int now){
    if(now == 0){
        return 1;
    }else{
        return burger_size(now - 1) * 2 + 3;
    }
}

int main(){
    int N;
    long X;
    cin >> N >> X;
    long ans = 0;
    for(int i = N; i >= 0; i--){
        if(i == 0){
            ans++;
            break;
        }
        if(X <= 1){
            break;
        }else if(X <= 1 + burger_size(i - 1)){
            X -= 1;
        }else if(X <= 1 + burger_size(i - 1) + 1){
            ans += power(2, i, 1e18);
            break;
        }else if(X <= 1 + burger_size(i - 1) + 1 + burger_size(i - 1)){
            ans += power(2, i, 1e18);
            X -= 1 + burger_size(i - 1) + 1;
        }else{
            ans += power(2, i, 1e18) + power(2, i, 1e18) - 1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define x first
#define y second
typedef long long ll;

using namespace std;

int main()
{_
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d)
        cout << "Left";
    else if (a+b < c+d)
        cout << "Right";
    else
        cout << "Balanced";



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int count = 0;
    for(int i = a; i <= b; i++){
        if(c%i == 0){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        final int N = scan.nextInt();
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = scan.next();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        scan.close();

    }

}


Measured memory_bytes: 56324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l[] = new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			l[i]=scan.nextInt();
			sum+=l[i];
		}
		scan.close();
		boolean tf=true;
		for(int i=0;i<n;i++) {
			if(l[i]>= sum-l[i]) {
				tf=false;
				break;
			}
		}
		System.out.println((tf)? "Yes":"No");
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll a, b;
    cin >> a >> b;
    vector<ll> c,d;
    for(ll i = 1; i <= sqrt(a); i++){
        if(a%i==0) {
            //cout << i << " " << a/i << endl;
            c.push_back(i);
            if(i!=a/i)
            c.push_back(a/i);
        }
    }
    sort(c.begin(), c.end());
    for(ll i = 0; i < c.size(); i++){
       // cout << c[i] << endl;
        if(b%c[i]==0)
            d.push_back(c[i]);
    }
    ll ans =1;
    //for(ll i = 0; i < d.size(); i++)
      //  cout << d[i] << endl;
    sort(d.begin(), d.end(), greater<ll>());
    for(ll i = 0; i < d.size()-1; i++){
        bool ok =true;
       // cout << d[i] << endl;
        for(ll j = i+1; j < d.size()-1; j++){
            if(d[i]%d[j]==0){
                ok = false;
                break;
            }
        }
        if(ok==true)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;cin>>n;
  string str="";
  while(n!=0){
    ll r=n%2;
    if(r<0) r+=2;
    n=(n-r)/(-2);
    str+=(char)('0'+r);
  }
  reverse(ALL(str));
  if(str=="") cout<<0<<endl;
  else cout<<str<<endl;
}

Measured memory_bytes: 256
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    if N == 0:
        print(X)
        return
    diff = 100
    ans = -1
    for i in range(102):
        if i in P:
            continue
        d = abs(i - X)
        if d < diff:
            diff = d
            ans = i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
//
//  main.cpp
//  B - Bounding
//
//  Created by Hashizo on 2019/06/16.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n,x;
	cin >> n >> x;

	int l[n];
	
	REP(i, n) {
		cin >> l[i];
	}

	int dp[n+1];

	REP(i, n+1) {
		dp[i] = 0;
	}
	
	int b;
	for (b = 0; b < n+1;  b++) {
		if(dp[b] > x) {
			break;
		}
//		if(b == 0) {
//			dp[b+1] = l[b];
//			continue;
//		}
		
		dp[b+1] = dp[b] + l[b];
	}
	
	cout << b << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.strip.to_i
ss = readlines.map {|line| line.strip.split('').map(&:to_i) }

graph = Array.new(n) { [] }

n.times do |i|
  n.times do |j|
    graph[i] << j if ss[i][j]==1
  end
end

color = []
color[0]=true
s = [0]

until s.empty?
  c = s.pop
  pc = color[c]
  graph[c].each do |t|
    if !color[t].nil? && color[t]==pc
      p -1; exit
    end
    next unless color[t].nil?

    color[t] = !pc
    s.push(t)
  end
end

INF=10**5
n.times do |i|
  n.times do |j|
    ss[i][j] = INF if ss[i][j]==0
    ss[i][j]=0 if i==j
  end
end

n.times do |via|
  n.times do |from|
    n.times do |to|
      ss[from][to] = ss[from][via] + ss[via][to] if ss[from][to] > ss[from][via] + ss[via][to]
    end
  end
end
#ss.each {|l|p l}

p ss.map{|l|l.max}.max+1

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

struct Card{char suit; int num;};

void merge(Card A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    Card L[n1], R[n2];
    for(int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1].num = 1000000000;
    R[n2].num = 1000000000;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++) {
        if(L[i].num <= R[j].num) {
            A[k] = L[i];
            i++;
        } else { 
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card A[], int left, int right) {
  if(left + 1 < right) {
      int mid;
      mid = (left + right) / 2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
  }
  return;
}

int partition(Card A[], int p, int r) {
    int x = A[r].num;
    int i = p - 1;
    for(int j = p; j < r; j++) {
        if(A[j].num <= x) {
            i = i + 1;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quicksort(Card A[], int p, int r) {
    if(p < r) {
        int q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
    return;
}

bool checkStable(Card A[], Card B[], int n){
    for(int i = 0; i < n; i++) {
        if(A[i].suit != B[i].suit) return false;
    }
    return true;
}

int main() {
    int n, ind;
    Card A[100001], B[100001];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> A[i].suit >> A[i].num;
        B[i] = A[i];
    }
    mergeSort(B, 0, n);
    quicksort(A, 0, n-1);
    if(checkStable(A, B, n)){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    for(int i = 0; i < n; i++) {
        cout << A[i].suit << " " << A[i].num << endl;
    }
    return 0;
}


Measured memory_bytes: 5460
#include <stdio.h>
#include <math.h>

int main(void) {
  int x, y;
  int bf_x, bf_y;
  int tn, tn1;
  int n;
  int i;
  int bool, dist, time;

  tn = 0;
  bf_x = bf_y = 0;
  bool = 1;
  scanf("%d", &n);

  for (i	= 0; i < n; i++) {
    scanf("%d%d%d", &tn1, &x, &y);
    dist = abs(x - bf_x) + abs(y - bf_y);
    time = tn1 - tn;
    if (dist <= time &&	(time -	dist) %	2 == 0) {
      bool = bool;
    } else {
      bool = 0;
    }
    bf_x = x; bf_y = y;
    tn = tn1;
  }

  printf("%s\n", bool ? "Yes" : "No");
  return 0;
}

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

using namespace std;

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

	int A, B, m;
	cin >> A >> B >> m;
	vector<int> a;
	vector<int> b;
	a.resize(A);
	b.resize(B);
	for(int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	for(int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
	for(int i = 0; i < m; ++i) {
		int x, y, c;
		cin >> x >> y >> c;
		--x;
		--y;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << '\n';
	return 0;
}


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

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

    vector<int> res;
    int pos = n;
    while (pos > 0)
    {
        int step = -1;
        rrep(i, m+1, 1)
            if (0 <= pos-i and s[pos-i] == '0')
            {
                step = i;
                break;
            }
        if (step == -1)
        {
            cout << -1 << endl;
            return 0;
        }
        pos -= step;
        res.push_back(step);
    }

    reverse(res.begin(), res.end());
    for (auto r: res)
        cout << r << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int a[20][20],dp[20][20];
int main(){
	int h,w;
	while(cin>>w>>h&&h+w){
		lol(i,h)lol(j,w)cin>>a[i][j];
		lol(i,h)lol(j,w){
			dp[i][j]=0;
			if(a[i][j]==1)continue;
			if(i){
				if(a[i-1][j]==0)dp[i][j]=dp[i-1][j];
				if(i>1)if(a[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(a[i][j]==0){
					if(j>0)if(a[i-1][j-1]==0)dp[i][j]+=dp[i-1][j-1];
					if(j<w-1)if(a[i-1][j+1]==0)dp[i][j]+=dp[i-1][j+1];
				}
			}
			else dp[i][j]=1;
		}
		int ans=0;
		lol(j,w){
			ans+=dp[h-1][j];
			if(h>=2)if(a[h-2][j]==2)ans+=dp[h-2][j];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long
#define mk make_pair

typedef pair<int,int> pi;

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

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

int H,W;
int G[505][505];
vector<int> vi;

int main()
{
    scanf("%d %d",&H,&W);

    _rep(i,1,H){
        _rep(j,1,W){
            scanf("%d",&G[i][j]);
        }
    }

    int i = 1;
    int j = 1;
    int ok = 1;
    int x,y;

    while(i <= H){
        j = 1;
        while(j <= W){
            if(ok && G[i][j]%2){
                ok = 0;
                x = i;y = j;
            }
            else if(!ok){
                vi.PB(x);vi.PB(y);
                vi.PB(i);vi.PB(j);
                x = i;y = j;
                if(G[i][j] % 2) ok = 1;
            }
            j++;
        }

        i++;
        if(i > H) break;

        j = W;
        while(j >= 1){
            if(ok && G[i][j]%2){
                ok = 0;
                x = i;y = j;
            }
            else if(!ok){
                vi.PB(x);vi.PB(y);
                vi.PB(i);vi.PB(j);
                x = i;y = j;
                if(G[i][j] % 2) ok = 1;
            }
            j--;
        }
        i++;
    }


    printf("%d\n",(int)(vi.size()/4));
    for(int i = 0; i < vi.size()/4;i++){
        printf("%d %d %d %d\n",vi[i*4],vi[i*4+1],vi[i*4+2],vi[i*4+3]);

    }


    return 0;
}


Measured memory_bytes: 5232
/*input
10000000019
*/
/**
    Author: Kristopher Paul
    Date Created: 27-10-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int mini = n-1;
    for(int i = 1;i <= sqrt(n);i++){
        if(n % i == 0){
            int x = i;
            int y = n/i;
            remin(mini,x-1+y-1);
        }
    }
    cout << mini << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		long N=sc.nextLong(),A=sc.nextLong(),B=sc.nextLong();
		Long ans=0L;

		ans+=N/(A+B)*A;
		if(N%(A+B)<A) {
			ans+=N%(A+B);
		}else if(N%(A+B)>=A){
			ans+=A;
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 22612
using System;
//floorは再帰で解く
//[a/b]=(a-a%b)/b

//[Ax/B]-A[x/B]=((Ax-Ax%B)/b)-A*(x-x%B)/B
//=>A(x%B)-(Ax%B)を最大化したい
//またAx%B=A(x%B)%Bなので
//=>[A(x%B)/B]
//=>x%Bの最大値を求める
//これの答えは基本的にはx=B-1だが、z<B-1の時は成り立たない

class Program{
    static void Main()
    {
        string[] In = Console.ReadLine().Split(' ');
        int a = int.Parse(In[0]);
        long b = long.Parse(In[1]);
        long n = long.Parse(In[2]);
        //y=x%B
        long y = 0;
        if (n >= b - 1)
        {
            y = b - 1;
        }
        else
        {
            y = n;
        }
        long ans = (a * y - ((a * y) % b))/b;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 27372
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    Scanner sin=new Scanner(System.in);
	    int n=sin.nextInt();
		Map<Integer,Boolean> mp=new HashMap<Integer, Boolean>();
	    boolean k=false;
		for (int i = 0; i < n; i++) {
			int data = sin.nextInt();
			if(mp.containsKey(data)){
				k=true;
			}else mp.put(data,true);
		}
		if(k) System.out.println("NO");
		else System.out.println("YES");
    }
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int n,m,a[2000005],b[2000005];

int main()
{
    sf(n);
    for(int i=0;i<n;i++)
    {
        int x;
        sf(x);
        b[x]++;
    }
    for(int i=1;i<=1000000;i++)
    {
        if(b[i])
        {
            for(int j=i+i;j<=1000000;j+=i)
            {
                a[j]=1;
            }
        }
    }
    int c=0;
    for(int i=1;i<=1000000;i++)
    {
        if(b[i]==1 && a[i]==0)
        {
            c++;
        }
    }
    pf("%d\n",c);
}


Measured memory_bytes: 11576
n = int(input().split()[0])
h_list = list(map(int, input().split()))

min_com_cost = [0]

for i in range(1, len(h_list)):
    # 1個前からくるパターン
    cost_1step = min_com_cost[i-1] + abs(h_list[i] - h_list[i-1])

    # 2個前からくるパターン
    if i > 1:
        cost_2step = min_com_cost[i-2] + abs(h_list[i] - h_list[i-2])
    else:
        cost_2step = float('inf')

    cost = min(cost_1step, cost_2step)
    min_com_cost.append(cost)

print(min_com_cost[-1])

Measured memory_bytes: 13928