akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int dp[101][100001];

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

int main() {
	int n, a, b, c, d[100];
	int ans = 0;
	cin >> n >> a >> b >> c;
	REP(i, n) scanf("%d", &d[i]);

	
	for(int i = 0; i < 100; i++) {
		for(int j = 0; j <= 100000; j++) {
			if (j >= b) dp[i + 1][j] = max(dp[i][j], dp[i][j - b] + d[i]);
			else dp[i + 1][j] = dp[i][j];
		}
	}

	REP(i, 100001) ans = max(ans, (c+dp[n][i]) / (a+i));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 40304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C;

	cin >> A >> B >> C;

	if (min(A, B) < C && C < max(A, B)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 22:59:45
*/

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


int main(){
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#pragma region def
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
using pint = pair<int, int>;
const int INF = 1e9;
const long long llINF = 1e18;
#pragma endregion

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

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

#define max(a,b)	(a>b?a:b)

int main(){
	char S[10];
	int i;
	int cnt;
	int m;
	int ans;
	
	gets(S);
	
	cnt=0;
	ans=0;
	for(i=0;i<strlen(S);i++){
		if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
			if(m==0){
				cnt++;
				m=1;
			}else if(m==1){
				cnt++;
			}
		}else{
			if(m==1){
				ans=max(ans,cnt);
				cnt=0;
				m=0;
			}
		}
	}
	
	if(m==1){
		ans=max(ans,cnt);
		cnt=0;
		m=0;
	}
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vector<ll>> candies(2, vector<ll>(N));
    for (int i = 0; i <= 1; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> candies.at(i).at(j);
        }
    }
    ll sitaCandies = 0;
    for (int i = 0; i < N; i++)
    {
        sitaCandies += candies.at(1).at(i);
    }
    ll ueCandies = candies.at(0).at(0);
    ll answer = ueCandies + sitaCandies;
    for (int i = 1; i < N; i++)
    {
        ueCandies += candies.at(0).at(i);
        sitaCandies -= candies.at(1).at(i - 1);
        answer = max(answer, ueCandies + sitaCandies);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int tax(int u,int v){
    return v*(100+u)/100;
    }
int X,Y,S;
int solve() {
    int maximum = 0;
    for (int i=1; i<S; ++i){
        for (int j=i; j<S; ++j){
             if (tax(X,i)+tax(X,j) == S)
             maximum = max(maximum, tax(Y,i)+tax(Y,j));

             
        }
    }
    return maximum;// (*) 5 maximum = max(maximum, tax(Y,i)+tax(Y,j));
}
int main() {
     while (cin >> X >> Y >> S && X>0) { 
     cout << solve() << endl; 
     } 
}


Measured memory_bytes: 3108
D,N = map(int, input().split())

if D == 0:
    if N == 100:
        print('101')
    else:
        print(N)
elif D == 1:
    if N == 100:
        print('10100')
    else:
        print(N*100)
else:
    if N == 100:
        print('1010000')
    else:
        print(N*10000)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
	   Scanner Ahmad=new Scanner(System.in);
	   int x,y;
	   x=Ahmad.nextInt();
	   y=Ahmad.nextInt();
	   if((x+y)%2==0) {
		   System.out.println((x+y)/2);
	   }
	   else {
		   System.out.println("IMPOSSIBLE");
	   }
   }
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size(), ans = N;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] != S[i + 1]) {
      ans = min(ans, max(i + 1, N - 1 - i));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
    }
    if a <= 8 && b <= 8 {
        println!("Yay!")
    } else {
        println!(":(")
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=0;
	ll N,M,K,G,A,B;
	string S,T;
	ll id=0;
	ll sum;bool F=true;
	bool AL[26];
	unordered_map<char,vector<int>> Q;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>S>>T;
	int loop=T.size();
	REP(i,loop){
		Q[T[i]].push_back(i);
	}
	REP(i,26){
		char q='A';
		for(auto x:Q['a'+i]){
			if(q=='A'){
				q=S[x];
				if(!AL[q-'a'])AL[q-'a']=true;
				else{F=false;}
			}else if(q!=S[x]){
				F=false;
				break;
			}
		}
	}
	cout<<(F?"Yes":"No")<<endl;

}

Measured memory_bytes: 1940
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;


int main(void){
  
  int N,M,ans=0;
   vector<int> H,T;

  cin >> N >> M;
 

  for(int i = 0; i< N;i++){
    int tmp;
    cin >> tmp;
    H.push_back(tmp);
    T.push_back(1);
  }

  for(int i = 0; i< M;i++){
    int A,B;
    cin >> A >> B;

    if(H.at(A-1) > H.at(B-1)){
      T.at(B-1)=0;
    }else if(H.at(B-1) > H.at(A-1)){
      T.at(A-1)=0;
    }else{
      T.at(A-1)=0;
      T.at(B-1)=0;
    }


  }

  for(int i = 0; i<N;i++){
    if(T.at(i)==1){
      ans++;
    }
  }
 
  cout << ans << endl;
 
  return 0;
}




Measured memory_bytes: 4252
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n; cin >> n;
  string s; cin >> s;

  int ans = 0;
  rep(i, 1000) {
    string t = to_string(i);
    while (si(t) <= 2) t = '0' + t;

    int cnt = 0;
    rep(j, n) {
      if (s[j] == t[cnt]) ++cnt;
      if (cnt == 3) {
        ++ans;
        break;
      }
    }
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

#define       pb                 push_back
#define       sf                 scanf
#define       pf                 printf
#define       mx                 300005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

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

int dx[] = {0, 0, +1, -1};
int dy[] = {+1,-1, 0,  0};
/*============GRAPH MOVES==================*/
//const int fx[] = {1, -1, 0, 0};
//const int fy[] = {0, 0, 1, -1};
//const int fx[] = {0, 0, 1, -1, -1, 1, -1, 1};  // Kings move
//const int fy[] = {-1, 1, 0, 0, 1, 1, -1, -1};  // Kings move
//const int fx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; // Knights move
//const int fy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; // Knights move
/*=========================================*/

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
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)); }
inline ll mod(ll a, ll m){ if(a<0) return m-(abs(a)%m); else if(a<m) return a; else return (a%m); }
inline string tstring(ll a) {stringstream ss; ss << a; string str = ss.str(); return str; }

ll a[mx];

int main()
{
    ll n, ans = 0;

    cin >> n;

    for(ll i = 1; i <= n; i++) cin >> a[i];

    for(ll i = 1; i <= 60; i++)
    {
        ll one = 0, zero = 0;

        for(ll j = 1; j <= n; j++)
        {
            if((a[j]&(1LL<<i-1LL))) one = modAdd(one, 1LL);
            else zero = modAdd(zero, 1LL);
        }

        ans = modAdd(ans, modMul(modMul(one, zero), modPow(2LL, i-1)));
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		double A[] = new double[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			A[i] = stdIn.nextDouble();
			sum = sum + 1.0/A[i];
		}
	    sum = 1.0 / sum;
	    System.out.println(sum);
		stdIn.close();
	}
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

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

    int64_t dp[61][3] = {0};
    dp[60][0] = 1;

    for(int d=59; d>=0; d--){
        for(int s=0; s<=2; s++){
            for(int k=0; k<=2; k++){
                int s2 = min(2, 2*s + nth_bit(N, d) - k);
                if(s2 >= 0) add(dp[d][s2], dp[d+1][s]);
            }
        }
    }

    int64_t ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App{
    import scala.io.StdIn._
    val Array(n,m,x,y) = readLine().split("\\s").map(_.toInt)
    val x_array = readLine().split("\\s").map(_.toInt)
    val y_array = readLine().split("\\s").map(_.toInt)

    val x_max = (x_array :+ x).max
    val y_min = (y_array :+ y).min

    if (x_max>=y_min){
      println("War")
    } else {
      println("No War")
    }
}

Measured memory_bytes: 25544
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		string ans="YES";
		while(ans=="YES"&&s.Length>0){
			if(s.Length<5){ans="NO";break;}
			if(s.Substring(s.Length-5)=="dream"||s.Substring(s.Length-5)=="erase"){s=s.Substring(0,s.Length-5);}
			else if(s.Length>=7&&s.Substring(s.Length-7)=="dreamer"){s=s.Substring(0,s.Length-7);}
			else if(s.Length>=6&&s.Substring(s.Length-6)=="eraser"){s=s.Substring(0,s.Length-6);}
			else{ans="NO";}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 29600
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
int main(){
	int n,t;
	int ans = 0;
	scanf("%d%d",&n,&t);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	for(int i = 1; i < n; i++){
		if(a[i+1] - a[i] < t) ans += a[i+1]-a[i];
		else ans += t;
	}
	cout<<ans+t<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = 0;

    if(b * 2 < a){
      ans = a - b * 2;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            var num = new int[4];
            while ((line = Console.ReadLine()) != null)
            {
                var s = line.Split(',')[1];
                if (s.Length == 2) num[2]++;
                else if (s[0] == 'A') num[0]++;
                else if (s[0] == 'B') num[1]++;
                else num[3]++;
            }
            foreach(var i in num) Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 5568
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<string> s(n);
    map<string,int> mp;
    int g=0;
    rep(i,n){
        cin>>s[i];
        mp[s[i]]++;
        if(mp[s[i]]>1) g++;
    }
    char x=s[0][s[0].size()-1];
    for(int i=1;i<n;i++){
        if(x==s[i][0]){

        }
        else{
            g++;
        }
        x=s[i][s[i].size()-1];
    }
    if(g>0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }

    
}

Measured memory_bytes: 256
using System;

	class Program
	{
		public static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());
			int[] array= new int[n];
			for(int k=0;k<n;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???

			for(int gap=2;(int)((Math.Pow(3,gap)-1)/2)<n;gap++)
			{			
				m++;
			}
			
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<m;i++)
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int j=0;j<m;j++)
			{
				cnt+=sort( array, n, G[j]);
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<m-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[m-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<n;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		public static int sort(int [] A,int n,int g)
		{
			int count=0;//??????????????°
			for (int k=0;k<g;k++)
			{
				
			for(int i=k+g;i<n;i+=g)
			{
				
				int v=A[i];
				int j=i-g;
				while(j>=0&&A[j]>v)
				{
					A[j+g]=A[j];
					j=j-g;
				count ++; //????????????????????§????????????????????§??????????????¢??????
				A[j+g]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 16656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
 
signed main(){
	IOS();
	string s;
	cin>>s;
	int flg = 0;
	rep(i,0,3){
		if(s[i]==s[i+1])flg=1;
	}
	if(flg)cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
constexpr int mod = 998244353;
template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    map<int,int>cnt;
    for(auto e : v) cnt[e]++;
    int ans = (v.front() == 0);
    for(auto itr : cnt){
        if(itr.first == 0){
            if(itr.second != 1) ans = 0;
        } else {
            if(cnt[itr.first - 1] == 0) ans = 0;
            else ans *= modpow(cnt[itr.first - 1],itr.second);
        }
        ans %= mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 7296
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = []
for i in range(N - K + 1):
    #print(data[i],data[i+K-1])
    ans.append(data[i+K-1] - data[i] + abs(data[i+K-1]))
    ans.append(data[i+K-1] - data[i] + abs(data[i]))
print(min(ans))

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

int main(){
  string s;
  cin >> s;
  int a=s.size(),b=0;
  for(int i=0; i<s.size(); i++){
      if(s[i]=='A'){
        a=min(a,i);
      }
        if(s[i]=='Z'){
          b=max(i,b);
        }
  }cout << b-a+1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int l=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==l+1){
            l++;
        }
    }
    if(l==0) cout<<"-1";
    else cout<<n-l;
}

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

int main() {
   int n;
   std::cin >> n;
   int a = 0;
   int tsuru = 0, kame = 0;
   while (a < n) {
      tsuru++;
      a += 7;
      //std::cout << a << "         \r";
      if (a == n) {
         std::cout << "Yes" << '\n';
         return 0;
      }
   }
   while (a > n && tsuru > 0) {
      tsuru--;
      a -= 3;
      //std::cout << a << "         \r";
      if (a == n) {
         std::cout << "Yes" << '\n';
         return 0;
      }
   }

   a = 0;

   while (a < n) {
      kame++;
      a += 4;
      //std::cout << a << "         \r";
      if (a == n) {
         std::cout << "Yes" << '\n';
         return 0;
      }
   }
   while (a > n && (kame -= 2) > 0) {
      /*
      a -= 8;
      if(a < 0) break;
      a += 7;*/
      a--;
      //std::cout << a << " " << kame << "         \n";
      if (a == n) {
         std::cout << "Yes" << '\n';
         return 0;
      }
   }
   std::cout << "No" << '\n';
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));

int k,q;

void solve(vector<ll> v){
    ll n,x,m;
    cin>>n>>x>>m;
    ll plus1=0; //1kaibunn
    ll cnt0=0; //0nokosuu
    for(int i=0;i<k;i++){
        v[i]%=m;
        if(v[i]==0) cnt0++;
        plus1+=v[i];
    }
    n--;
    ll loop=n/k;
    ll sum=loop*plus1;
    cnt0*=loop;
    for(int i=0;i<n-loop*k;i++){
        sum+=v[i];
        if(v[i]==0) cnt0++;
    }
    ll kosita=sum/m;
    if(sum%m+x%m>=m) kosita++;
    cout<<n-kosita-cnt0<<endl;
}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    
    cin>>k>>q;
    vector<ll> d(k);
    for(int i=0;i<k;i++) cin>>d[i];

    while(q--) solve(d);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	cout << min(a, min(b, c)) + min(d, e) - 50 << endl;
	return 0;
}

Measured memory_bytes: 3068
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll sum = 0;
    ll A[N];
    F0R(i, N) {
        cin >> A[i]; sum ^= A[i];
    }

    sum ^= A[0] ^ A[1];
    ll total = A[0] + A[1];

    ll dp[2]; dp[0] = -1e15; dp[1] = 0;
 //   cout << sum << nl;
    F0Rd(bit, 45) {
        if (sum & (1ll << bit)) {

            if (A[0] & (1ll << bit)) {
                dp[0] += (1ll << bit);
                ckmax(dp[0], dp[1]);
                dp[1] += (1ll << bit);
            } else {
                dp[0] += (1ll << bit);
            }
            total -= (1ll << bit);
        } else {
            if (total >= (1ll << (bit+1))) {
                if (!(A[0] & (1ll << bit))) {
                    dp[1] = -1e15;
                }
                dp[0] += (1ll << bit);
                dp[1] += (1ll << bit);
                total -= 1ll << (bit+1);
            } else {
                if (A[0] & (1ll << bit)) {
                    ckmax(dp[0], dp[1]);
                }
            }
        }
//        cout << bit << " " << dp[0] << " " << dp[1] << nl;
    }

    if (total == 0 && (dp[0] > 0 || dp[1] > 0)) {
        cout << A[0]-max(dp[0], dp[1]) << nl;
    } else {
        cout << -1 << nl;
    }


	
	return 0;
}
 


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int out;
int dx[]={0,1,1,1};
int dy[]={1,-1,0,1};
void dfs(vi &in){
	rep(i,in.size()){
		int x=i/4,y=i%4;
		rep(j,4){
			int nx=x+dx[j],ny=y+dy[j];
			if(nx<0||ny<0||nx>=5||ny>=4)continue;
//			cout<<x<<" "<<y<<" "<<nx<<" "<<ny<<endl;
			int t=nx*4+ny;
			if(t>=in.size())continue;
			if(in[i]==in[t]){
				vi tm=in;
				tm.erase(tm.begin()+t);
				tm.erase(tm.begin()+i);
				out=min(out,(int)tm.size());
				dfs(tm);
			}
		}
	}
}
int main(){
	int q;
	cin>>q;
	while(q--){
		vi in(20);
		rep(i,20)cin>>in[i];
		out=20;
		dfs(in);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 2924
discount_A=(380 * 5 * 0.8).to_i
discount_B=(550 * 4 * 0.85).to_i
discount_C=(850 * 3 * 0.88).to_i
loop do
    s=gets.chomp.to_i
    break if (s==0)
    min_cost=100000
    s/=100
    for i in 0..(s/2)
        gA=s-2*i
        for j in 0..(gA/3)
            gB=gA-3*j
            if(gB%5==0)
                k=gB/5
                cost_A=(i/5)*discount_A+(i%5)*380
                cost_B=(j/4)*discount_B+(j%4)*550
                cost_C=(k/3)*discount_C+(k%3)*850
                x=cost_A+cost_B+cost_C
                min_cost=[x,min_cost].min
            end
        end
    end
    p min_cost
end

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

using namespace std;

int main(){
  int n; cin >> n;
  int k; cin >> k;
  
  if( k > n ) {
    cout << "0" << endl;
    return 0;
  }

  vector<int> h(n);
  int v = 0;
  for(int i = 0; i < n; i++) {
    cin >> v;
    h[i] = v;
  }
  
  long res = 0;
  if( k == 0 ) {
    for(int i = 0; i < n; i++) {
      res += h[i];
    }
    cout << res << endl;
    return 0;
  }
  
  std::sort(h.begin(), h.end(), greater<int>() );
  for(int i = 0; i < n; i++) {
    if( k <= 0 ) {
	  res += h[i];
    }
    k--;
  }

  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ll ans=0;
    ans=(n*(n+1))/2-n;
    cout<<ans<<endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<vector<int>> T(4,vector<int>(13,0));
	int N=in();
	REP(i,N){
		char c = in<char>();
		int n = in()-1;
		switch(c){
		case 'S':
			T[0][n] = 1;
			break;
		case 'H':
			T[1][n] = 1;
			break;
		case 'C':
			T[2][n] = 1;
			break;
		default:
			T[3][n] = 1;
			break;
		}
	}
	char m[4]={'S','H','C','D'};
	REP(i,4){
		REP(j,13){
			if(!T[i][j]){
				out(m[i],j+1);
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3196
from collections import defaultdict

N = int(input())
c = defaultdict(int)
s = 0
c[s] += 1
for a in list(map(int, input().split())):
    s += a
    c[s] += 1
print(sum(list(map(lambda v: v * (v - 1) // 2, c.values()))))


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

using namespace std;

int dp[100010];

int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 1; pow(6, i) <= N; i++) A.push_back(pow(6, i));
  for (int i = 1; pow(9, i) <= N; i++) A.push_back(pow(9, i));
  fill(dp, dp + sizeof(dp) / sizeof(dp[0]), numeric_limits<int>::max());
  dp[0] = 0;

  for (int a : A) {
    for (int i = 0; i + a <= N; i++) {
      if (dp[i] == numeric_limits<int>::max()) continue;
      dp[i + a] = min(dp[i + a], dp[i] + 1);
    }
  }

  int answer = numeric_limits<int>::max();
  for (int i = 0; i <= N; i++) {
    if (dp[i] == numeric_limits<int>::max()) continue;
    answer = min(answer, dp[i] + N - i);
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    int main() {
        int N;
        cin >> N;
        vector<int> vec(N);
        for (int i = 0; i < N; ++i) cin >> vec[i];
        sort(vec.begin(), vec.end());
     
        int ans = 0;
     
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < i; ++j) {
                for (int k = 0; k < j; ++k) {
                    if (vec[k] != vec[j] and vec[i] != vec[j] and
                        vec[k] + vec[j] > vec[i]) {
                        ans++;
                    }
                }
            }
        }
     
        cout << ans << endl;
     
        return 0;
    }

Measured memory_bytes: 3604
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    writeln(A * B % 2 == 0 ? "Even" : "Odd");
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  vi a(3);
  int k;
  cin >> a[0] >> a[1] >> a[2] >> k;
  vsort(a);

  rep(i,k)
  {
    a[2] = a[2] * 2;
  }

  cout << a[0] + a[1] + a[2] << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    loop = int(N ** 0.5)

    ans = float("inf")
    for i in range(1, loop + 1):
        if N % i == 0:
            j = N // i
            tmp = i + j - 2

            if tmp < ans:
                ans = tmp
    print(ans)


if __name__ == "__main__":
    main()

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n,root;
ll stone[100000];
vector<int> G[100000];

void dfs(int v,int prv) {
	ll child_sum=0,ma=-1;
	if((int)G[v].size()==1) {
		return;
	}
	REP(i,(int)G[v].size()) {
		int u=G[v][i];
		if(u==prv) continue;
		dfs(u,v);
		child_sum+=stone[u];
		ma=max(ma,(ll)stone[u]);
	}
	if(stone[v]*2<child_sum||stone[v]>child_sum||stone[v]<ma) {
		cout<<"NO"<<endl;
		exit(0);
	}
	stone[v]=2*stone[v]-child_sum;
}

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

	cin>>n;
	REP(i,n) cin>>stone[i];
	REP(i,n-1) {
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].pb(b),G[b].pb(a);
	}
	if(n==2) {
		cout<<(stone[0]==stone[1]?"YES":"NO")<<endl;
		return 0;
	}
	while((int)G[root].size()==1) root++;
	dfs(root,-1);
	cout<<(stone[root]==0?"YES":"NO")<<endl;

	return 0;
}


Measured memory_bytes: 13184
/**
  * @file pb.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-09-23
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 128
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int x[N],y[N];

int main()
{
    int n,m;
    scanf("%d%d%d%d",&n,&m,x,y);
    for(int i=1;i<=n;++i)scanf("%d",x+i);
    for(int i=1;i<=m;++i)scanf("%d",y+i);
    puts(*std::max_element(x,x+n+1)<*std::min_element(y,y+m+1)?"No War":"War");
    return 0;
}


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

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

    cout<<(sum-N)<<endl;

    return 0;
}

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

int main()
{
	int n;
	int a = 0, b = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int A, B;
		cin >> A >> B;
		if (a < A)
		{
			a = A;
			b = B;
		}
	}
	cout << a + b << endl;;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using lb=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
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; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
           bool ans[4];


int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           int n=s.size();
           rep(i,0,n){
             if(s[i]=='W')ans[0]=1;
             else if(s[i]=='E')ans[1]=1;
             else if(s[i]=='N')ans[2]=1;
             else ans[3]=1;
           }
           Yes((ans[0]==ans[1])&&(ans[2]==ans[3]));
}

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

int main(){
  int k,count=0;
  int num[3];
  cin>>num[0]>>num[1]>>num[2]>>k;
  int coins[num[0]+1][num[1]+1][num[2]+1];
  for(int i=0;i<=num[0];i++){
    for(int j=0;j<=num[1];j++){
     	for(int p=0;p<=num[2];p++){
          coins[i][j][p] = 500*i + 100*j +50*p;
          if(coins[i][j][p] == k){
            count++;
            break;
          }else if(coins[i][j][p]>k) break;
        }
      if(coins[i][j][0]>k) break;
    }
    if(coins[i][0][0]>k) break;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func Digit(n int) int {
	digit := 0
	s := strconv.Itoa(n)
	for _, c := range s {
		r, _ := strconv.Atoi(string(c))
		digit += r
	}
	return digit
}

func main() {
	n, a, b := readInt(), readInt(), readInt()
	sum, digit := 0, 0
	for i := 1; i <= n; i++ {
		digit = Digit(i)
		if a <= digit && digit <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}


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

int main(void)
{
    long long a, b, c;

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> a >> b;
        if (a > b)
        {
            swap(a, b);
        }
        
        if (a == b || a + 1 == b)
        {
            cout << 2 * a - 2;
        }
        else
        {
            c = sqrt(a * b);
            if (c * c == a * b)
            {
                c--;
            }
            if (c * (c + 1) >= a * b)
            {
                cout << 2 * c - 2;
            }
            else
            {
                cout << 2 * c - 1;
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=get_nsp.map(&:to_i)
L=N.size
i=1
(L-1).times do
  if N[i]!=9
    N[i-1]-=1
    break 
  else
      i+=1
  end
end
puts N[0..i-1].inject(:+)+9*(L-i)

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var c [3][3]int
	for i := 0; i < 3; i++ {
		fmt.Scan(&c[i][0], &c[i][1], &c[i][2])
	}

	a := make([]int, 3)
	b := make([]int, 3)

	a[0] = 0
	b[0] = c[0][0]
	b[1] = c[0][1]
	b[2] = c[0][2]
	a[1] = c[1][0] - b[0]
	a[2] = c[2][0] - b[0]

	for i, ci := range c {
		for j, cj := range ci {
			if cj != a[i]+b[j] {
				fmt.Print("No")
				return
			}
		}
	}

	fmt.Print("Yes")
}


Measured memory_bytes: 512