akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int n, k, r, s, p;
    cin >> n >> k;
    vector<int> rsp(3);
    cin >> rsp[0] >> rsp[1] >> rsp[2];
    string t;
    cin >> t;
    vector<int> pnt(n);
    rep(i,n) {
        if (t[i] == 'r') pnt[i] = 2;
        else if (t[i] == 's') pnt[i] = 0;
        else if (t[i] == 'p') pnt[i] = 1;
    }
    int ans = 0;
    rep(i,k) {
        int now = pnt[i], cnt = 0, res = 0;
        for (int id = i; id < n; id += k) {
            if (pnt[id] == now) {
                cnt ++;
            }
            else {
                res += ((cnt + 1) / 2) * rsp[now];
                now = pnt[id];
                cnt = 1;
            }
        }
        res += ((cnt + 1) / 2) * rsp[now];
        ans += res;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 896
a, b, c = map(int, input().split())
cnt = 0
while True:
    if a == b == c and a%2 == 0:
        cnt = -1
        break
    elif a%2 != 0 or b%2 != 0 or c%2 != 0:
        break
    elif a%2 == 0 and b%2 == 0 and c%2 == 0:
        a, b, c, = (b+c)//2, (a+c)//2, (a+b)//2
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int n=sc.nextInt();
        int[]a=new int[n];
        int b[]=new int[n];
        a[0]=sc.nextInt();
        int max=a[0];
        for(int i=1;i<n;i++){
            a[i]=sc.nextInt();
            max=Math.max(a[i]-a[i-1],max);
        }
        max=Math.max(a[0]+(k-a[n-1]),max);
        System.out.println(k-max);
    }
}


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


void solve(long long N, long long M, std::vector<long long> A){
int sum=0;
for(int i=0; i<M; i++){
    sum+=A.at(i);
}
if(N-sum<0){
    cout<<"-1"<<endl;
}else cout<<N-sum<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

struct Edge { int to, id;};


int main() {
  int n;
  cin >> n;
  vector<vector<Edge>> g(n);
  vector<int> ans(n-1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }

  queue<int> q;
  vector<int> used(n);
  q.push(0);
  used[0] = 1;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    int c = -1;
    rep(i,g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) c = ans[ei];
    }
    int k = 1;
    rep(i,g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) continue;
      if (k == c) ++k;
      ans[ei] = k; ++k;
      q.push(u);
      used[u] = 1;
    }
  }

  int mx = 0;
  rep(i,n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i,n-1) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 7296
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0): break
    ans = []
    for i in range(n, 1, -1):
        for j in range(1, n):
            tmp = x-(i+j)
            if tmp > n: continue
            if tmp > 0 and i > 0 and j > 0:
                if tmp != j and tmp != i and i != j:
                    pmt = sorted([i, j, tmp])
                    if not pmt in ans: ans.append(pmt)
    print(len(ans))



Measured memory_bytes: 5604
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int n, tot, W, tot2;
string s;

int main() {
	scanf("%d", &n);
	cin>>s;
	for(int i=0;i<n;i++) {
		if(s[i] == 'W') {
			if(!W) {
				W = i;
			}
		}
		else {
			++tot;
		}
	}
	for(int i=0;i<tot;i++) {
		if(s[i] != 'R') {
			++tot2;
		}
	}
	printf("%d\n", min(tot2, n-W));
	return 0;
}

Measured memory_bytes: 3872
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    N, M, X, Y = map(int, sys.stdin.readline().rstrip().split())
    x = list(map(int, sys.stdin.readline().rstrip().split()))
    x = max(X, max(x))
    y = list(map(int, sys.stdin.readline().rstrip().split()))
    y = min(Y, min(y))
    if x < y:
        print('No War')
    else:
        print('War')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		good = bad = -1;
	}
	int good,bad;
};

int main(){

	int N,M,count = 0,index = 0,sum = 0;

	scanf("%d %d",&N,&M);
	Info info[M];

	int left,right;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&left,&right);
		if(left >= N){
			count++;
		}else{
			info[index].good = left;
			info[index].bad = right;
			index++;
		}
	}

	if(count < M-1){
		for(int i = 1; i <= index-1; i++){
			for(int k = index-1; k >= i; k--){
				if(info[k].good > info[k-1].good)swap(info[k],info[k-1]);
			}
		}

		for(int i = 0; i < index; i++){
			sum += (N-info[i].good);
			count++;
			if(count == M-1)break;
		}
	}

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

	return 0;
}

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

using namespace std;

vector<vector<long long int>> mem(100000+1, vector<long long int>(101, 0ll));

int main() {
    int n, w;
    scanf("%d %d", &n, &w);
    vector<int> v(n+1, 0), wg(n+1, 0);
    for(int i = 1; i <= n; i++) {
        scanf("%d %d", &wg[i], &v[i]);
    }
    long long int temp;
    for(int i = 1; i <= w; i++) {
        for(int j = 1; j <= n; j++) {
            // if(!j && i >= wg[j]) {
            //     mem[i][j] = v[j];
            //     continue;
            // }
            temp = i >= wg[j] ? mem[i-wg[j]][j-1] + v[j] : LONG_MIN;
            mem[i][j] = max(temp, mem[i][j-1]);
        }
    }
    cout << mem[w][n] << endl;
    return 0;
}


Measured memory_bytes: 82304
#include <stdio.h>
#define MAX 100
int n,G[MAX][MAX],d[MAX],f[MAX]={0},Time=0;
void Visit(int);

int main(){
    int i,j,u,k,v;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        d[i]=0;
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            G[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            G[u-1][v-1]=1;
        }
    }
    for(i=0;i<n;i++){
        if(d[i]==0) Visit(i);
    }
    for(i=0;i<n;i++){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }
    return 0;
}
void Visit(int u){
    int i,j,p;
    Time++;
    d[u]=Time;
    for(p=0;p<n;p++){
        if(d[p]==0 && G[u][p]==1) Visit(p);
    }
    Time++;
    f[u]=Time;
}

Measured memory_bytes: 636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

using namespace std;

int main(){
    int n;
    while(cin>>n && n){
        bool na = true;
        int i[1000], p[1000], q[1000], r[1000];
        rep(j,n){
            cin>>i[j]>>p[j]>>q[j]>>r[j];
        }
        int pp,qq,rr,cc;
        cin>>pp>>qq>>rr>>cc;
        rep(j,n){
            if(p[j]<=pp && q[j]<=qq && r[j]<=rr && p[j]*4+q[j]*9+r[j]*4<=cc){
                na=false;
                cout<<i[j]<<endl;
            }
        }
        if(na){
            cout<<"NA"<<endl;
        }
    }
}    

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

main()
{
    int a[3]; cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[1]==a[0] and a[0]<a[2]) cout << "Yes" << "\n";
    else if(a[1]==a[2] and a[1]>a[0]) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

int main(){
  int n, num[3], min = 100000000, flag;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> num[i];
    if(min > num[i]) min = num[i];
  }
  for(int j=1;j<=min;j++){
    flag = 1;
    for(int i=0;i<n;i++){
      if(num[i] % j) flag = 0;
    }
    if(flag) cout << j << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
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<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    deque<ll> v;
    rep(i,N){
        ll a = A[i];
        if(v.size() == 0){
            v.push_front(a);
            continue;
        }
        auto itr = lower_bound(v.begin(),v.end(),a);
        //cout << "i"<<i << endl;
        if(itr == v.begin()){
            v.push_front(a);
        }else{
            //cout << "q" << itr-v.begin() << endl;
            *(itr-1) = a;
            
        }
    }
    cout << v.size() << endl;
}

Measured memory_bytes: 4780
#include <iostream>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

string s[] = {"sat","sun","mon","tue","wed","thu","fri"};

int main(){
  int x;
  cin >> x;
  cout << s[(x - 2 + 7) % 7] << endl;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    string ret = "kogakubu10gokan";
    for(int i=0; i<n; ++i){
        int a;
        string s;
        cin >> a >> s;
        if(a <= q)
            ret = s;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
// 公共
int dp[1005][1005];
void solve(){
	memset(dp,0,sizeof(dp));
	for(int i=1;i<s1.length();i++)
		for(int j=1;j<=s2.length();j++)
			dp[i][j]=(s1[i]==s2[j]?dp[i-1][j-1]+1:max(dp[i-1][j],dp[i][j-1]));
	cout<<dp[s1.length()-1][s2.length()-1]<<endl;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//	freopen("a.txt","r",stdin);
	int T;cin>>T;
	while(T--){
		cin>>s1>>s2;
		s1=" "+s1;
		s2=" "+s2;
		solve();		
	}
	return 0;
}


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

int main() {
  string s;
  cin>>s;
  int n = s.size();
  int count=0;
  
  for(int i=0;i<n;i=i+2){
    if(s[i]!=s[0]) count++;
  }
  if(n>=1){
  for(int i=1;i<n;i=i+2){
    if(s[i]!=s[0]){}
    else count++;
  }
  }else count =0;

  if(count<=n/2)cout<<count<<endl;
  else cout<<n - count<<endl;
  
  return 0;
}

Measured memory_bytes: 512
W, H, N = list(map(int, input().split()))
left = 0
right = W
bottom = 0
top = H
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    elif a == 4:
        top = min(top, y)
print(max(0, right-left)*max(0, top-bottom))

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    vector<unsigned long> v(K + 1);
    unsigned long ans{0};
    for(unsigned long i{K}; i > 0; --i){
        if(!v[K / i]){
            v[K / i] = modpow(K / i, N);
            for(unsigned long j{2 * i}; j <= K; j += i)v[K / i] += MOD - v[K / j];
            v[K / i] %= MOD;
        }
        ans += i * v[K / i] % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	(b-a == c-b)? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int t = in.nextInt();
		int[] c = new int[n];
		int[] tn = new int[n];
		for(int i = 0; i < n; i++){
			c[i] = in.nextInt();
			tn[i] = in.nextInt();
		}
		int result = 1001;
		
		for(int i = 0; i < n; i++){
			if(tn[i] <= t && c[i] < result)
				result = c[i];
		}
		
		if(result == 1001)
			System.out.println("TLE");
		else
			System.out.println(result);

	}

}

Measured memory_bytes: 22868
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)
	count := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 4492
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
  if(N==M){
    cout<<"Yes"<<endl;
    return;
  }
  cout<<"No"<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
// #include <unordered_map>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
#define debug(x) cout << #x << " " << x << "\n"
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
#ifdef DEBUG
const int MAX = 2e3 + 50;
#else
const int MAX = 1e6 + 50;
#endif
const int mod = 1e9 + 7;

int a[MAX];
int Next[MAX];
int sum, Xor;
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)  scanf("%d", &a[i]);
    Next[n] = n;
    for(int i = n-1; i >= 0; i--){
        if(a[i] == 0) Next[i] = Next[i+1];
        else{
            Next[i] = i;
        }    
    }
    LL ans = 0;
    for(int i = 0; i < n; i++){
        sum = Xor = 0;
        int j, k;
        sum = Xor = a[i];
        for(j = i, k = Next[i+1]; k < n and j - i + 1<= 25; j++, k = Next[k+1]){
            sum += a[k];
            Xor ^= a[k];
            if(sum != Xor) break;
        }
        ans += (LL)k - i;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int A,B,K;
int main(){
    cin>>A>>B>>K;
    if(A+K-1>=B-K+1){
        for(int i=A;i<=B;i++)
            cout<<i<<"\n";
    }else{
        for(int i=A;i<A+K;i++)
            cout<<i<<"\n";
        for(int i=B-K+1;i<=B;i++)
            cout<<i<<"\n";
    }    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
A=[int(input()) for i in range(n)]
flag=1
ans=0
c=0
M=0
while(A):
    a=A.pop()
    M-=1
    n-=1
    if n < a:
        flag = 0
#        print(n,a,ans,"case n dekai")
        break
#    print(M,a,"MA")
    if M > a:
        flag = 0
#        print(n,a,ans,"case n dekai")
        break
    M=max(M,a)
#    print(A,n,a,"A n a")
    
    if c == 0:
        ans+=a
#        print(a,"ans++")
    if n==0:
        break

    if a-1 == A[-1]:
#        print(A,a,ans,"kati")
        c=1
    else:
#        print(A,a,ans,"aiko")
        c=0

        

if flag==0:
    print(-1)
else:
    print(ans)



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll n;
  cin >> n;
  ll ans = n;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, i + n / i - 2);
    }
  }
  cout << ans << endl;
}


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

int main(){
	int a, b, sum = 0;
	cin >> a >> b;

	if (a > b){
		sum += a;
		a -= 1;
	}
	else{
		sum += b;
		b -= 1;
	}

	if (a > b){
		sum += a;
	}
	else{
		sum += b;
	}

	cout << sum << endl;

	return 0;
}

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//指定了间隔g的插入排序
void insertionSort(int A[], int n, int g)
{
	for (int i = g; i < n; i++)
	{
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n)
{
	//生成数列G={1，4，13，40，121···};
	for (int g = 1;;)
	{
		if (g > n) break;
		G.push_back(g);
		g = 3 * g + 1;

	}
	for (int i = G.size() - 1; i >= 0; i--)
	{
		insertionSort(A, n, G[i]);
	}
}
int main()
{
	cin >> n;
	//scanf输入速度更快
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	cnt = 0;

	shellSort(A, n);

	cout << G.size() << endl;
	for (int i = G.size()-1; i >=0; i--)
	{
		printf("%d", G[i]);
		if (i) printf(" ");
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++)
		printf("%d\n", A[i]);
	return 0;
}


Measured memory_bytes: 7196
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) begin(x),end(x)
#define msi map<string,int>
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define sh short int
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
const int shift = 2e6;
int n;
int a[109];
int main(){
    fast,cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]%2) continue;
        if(a[i]%3 && a[i]%5){
            cout<<"DENIED"<<endl; return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
typedef long long ll;

using namespace std;

int main(void)
{
    int cnt;

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

    for (int i = 0; i < 5; i++) {
        if (v[i] == 0) {
            cnt = i+1;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int[] list = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
		System.out.println(list[k - 1]);
	}

}


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

int main() {
    ll n;
    std::cin >> n;
    if(n==1){
        std::cout << 1 << std::endl;
        return 0;
    }
    
    set<ll> element;
    ll nown = n;
    for (int i = 2; i <= sqrt(n); i++) {
        if(nown%i==0){
            element.insert(i);
        }
        while(nown%i==0){
            nown/=i;
        }
    }
    if(nown!=1){
        element.insert(nown);
    }
    // 素数のとき
    if(element.empty()){
        element.insert(n);
    }
    
    ll result = n;
    
    for (auto e : element) {
        // std::cout << e << std::endl;
        result /= e;
        result *= (e-1);
    }
    
    std::cout << result << std::endl;
    
}



Measured memory_bytes: 3124
import java.net.SecureCacheResponse;
import java.util.Random;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
 
        int a ,b, c;
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
 
        if(a + b == c || b + c == a || c + a == b){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
 
 
    }
}

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

typedef long long ll;
const int MAX = 1e5;

int n;
int a[MAX];

ll solve(bool flag, ll sum) {
  ll res = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (flag) {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    } else {
      if (sum <= 0) {
        res += -sum + 1;
        sum = 1;
      }
    }
    flag = !flag;
  }

  return res;
}

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

  // 貪欲法で操作回数の最小値を求める
  // プラスから始まるパターンとマイナスから始まるパターンの2パターン試して、その小さい方が答え
  cout << min(solve(true, 0), solve(false, 0)) << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 4001;
ll ans = 0;
int n, k;
ll p2[mxN];
ll nCr[mxN][mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>k>>n;
    nCr[0][0] = 1;
    owo(i, 1, mxN) {
        owo(j, 0, mxN) {
            nCr[i][j] = nCr[i-1][j];
            if(j) {
                nCr[i][j] = (nCr[i][j] + nCr[i-1][j-1])%MOD;
            }
        }
    }
    p2[0] = 1;
    owo(i, 1, mxN) {
        p2[i] = (p2[i-1]*2)%MOD;
    }
    owo(i, 2, 2*k+1) {
        ll res = 0;
        int bad = 0;
        int good = 0;
        owo(j, 1, k+1) {
            if(j*2==i)continue;
            if(i-j>0&&i-j<=k)bad++;
            else good++;
        }
        bad/=2;
        //cout<<i<<" "<<bad<<" "<<left<<" "<<distrib<<"\n";
        owo(j, 0, bad+1) {
            if(j>n)break;
            if(j==0&&good==0)continue;
            ll curr = (nCr[bad][j]*p2[j])%MOD;
            //cout<<spots<<"\n";
            res = (res + curr*nCr[n + good - 1][j + good - 1])%MOD;
            if((i&1)==0) {
                //ayaya;
                res = (res + curr*nCr[n + good - 2][j + good - 1])%MOD;
            }
        }
        cout<<res<<"\n";
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  set<int> d;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    d.insert(s);
  }
  
  cout << d.size() << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
if n>=m:
  print(0)
  exit()
b=[]
for i in range(m-1):
  b.append(a[i+1]-a[i])

b.sort()
b=b[:m-n]
print(sum(b))

Measured memory_bytes: 20420
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m;
vector<int> E[N];

void No() {
	puts("No");exit(0);
}

void Yes() {
	puts("Yes");exit(0);
}

namespace flow {

	struct edge {
		int to,w,nxt;
	} e[N<<1];

	int tot=1,h[N],dep[N],cur[N],s,t;

	void adde(int u,int v,int w) {
		e[++tot]=(edge){v,w,h[u]};h[u]=tot;
		e[++tot]=(edge){u,0,h[v]};h[v]=tot;
	}

	bool bfs() {
		memset(dep,0,sizeof(dep));
		queue<int> q;q.push(s);dep[s]=1;
		while(!q.empty()) {
			int u=q.front();q.pop();
			for(int i=h[u];i;i=e[i].nxt)
				if(e[i].w) {
					int v=e[i].to;
					if(!dep[v]) dep[v]=dep[u]+1,q.push(v);
				}
		}
		return dep[t];
	}
	
	int dfs(int u,int flow) {
		if(u==t) return flow;
		int ret=0;
		for(int &i=cur[u];i;i=e[i].nxt)
			if(e[i].w) {
				int v=e[i].to;
				if(dep[v]==dep[u]+1) {
					int d=dfs(v,min(flow,e[i].w));
					e[i].w-=d,e[i^1].w+=d,ret+=d,flow-=d;
					if(!flow) break;
				}
			}
		return ret;
	}

	int dinic(int _s,int _t) {
		s=_s,t=_t;
		int ret=0;
		while(bfs()) {
			memcpy(cur,h,sizeof(h));
			ret+=dfs(s,1e9);
		}
		return ret;
	}
	
}

int main() {
	n=gi(),m=gi();
	for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),E[u].push_back(v),E[v].push_back(u);
	for(int i=1;i<=n;i++) {
		if(E[i].size()&1) No();
	}
	for(int i=1;i<=n;i++) {
		if(E[i].size()>=6) Yes();
	}
	int cnt=0;
	for(int i=1;i<=n;i++) {
		if(E[i].size()>=4) ++cnt;
	}
	if(cnt>=3) Yes();
	if(cnt==2) {
		int A=0,B=0;
		for(int i=1;i<=n;i++)
			if(E[i].size()==4) {
				if(!A) A=i;
				else B=i;
			}
		for(int u=1;u<=n;u++)
			for(auto v:E[u]) flow::adde(u,v,1);
		if(flow::dinic(A,B)==2) Yes();
		No();
	}
	No();
	return 0;
}


Measured memory_bytes: 46336
#include <stdio.h>

int main(void)
{
	int i,n,a[10000],min,max;
	long long int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	min = a[0];
	max = a[0];
	for(i=1;i<n;i++)
	{
		if(min>a[i])
		{
			min = a[i];
		}
		if(max<a[i])
		{
			max = a[i];
		}
	}
	printf("%d %d %lld\n",min,max,sum);		
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) {
        cin >> a[i];
        --a[i];
    }

    int bef = 0;
    int loop = 0;
    int now = 0;
    int count = 0;
    vint f(n, -1);
    while (1) {
        if (count == k) {
            cout << now+1 << endl;
            return 0;
        }
        if (f[now] == -1) f[now] = count;
        else {
            bef = f[now];
            loop = count - f[now];
            break;
        }
        now = a[now];
        count++;
    }

    ll rem = k;
    rem -= bef;
    rem %= loop;
    while (1) {
        if (rem == 0) {
            cout << now+1 << endl;
            return 0;
        }
        now = a[now];
        rem--;
    }
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    int x = 0, y = 0;
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0)
            x += a[i];
        else
            y += a[i];
    }
    cout << x - y;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char o[55], e[55];
    int i;
    scanf ("%s %s", o, e);
    for (i = 0; o[i] != '\0'; i++)
    {
        if (o[i] == '\0' && e[i] == '\0') break;
        else if (e[i] == '\0') printf ("%c", o[i]);
        else printf ("%c%c", o[i], e[i]);
    }
    return (0);
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  ll S;
  cin >> S;
  ll MAX = 1e9;
  ll rem = S % MAX;
  ll quo = S / MAX;
  ll x1, y1, x2, y2, x3, y3;
  x1 = y1 = 0ll;
  x2 = 1ll;
  y2 = 1e9;
  if (rem == 0) {
    x3 = quo;
    y3 = 0;
  } else {
    x3 = quo + 1;
    y3 = (ll)1e9 - rem;
  }
  cout << x1 << " " << y1 << " " << x2<< " "  << y2 << " " << x3 << " " << y3 << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n; cin >> n;
	int m; cin >> m;
	int roop=1;
	for(int i=2;i<n;i++)
	{
		roop*=i;
	}

	vector<vector<int >> ab(n,vector<int>(n));
	rep(i,n)
		rep(j,n)
		{
			ab[i][j]=0;
		}

	rep(i,m)
	{
		int foo,fooo;
		cin >> foo >> fooo;
		ab[foo-1][fooo-1]=1;
		ab[fooo-1][foo-1]=1;
	}

	vector<int> root(n);
	rep(i,n)root[i]=i;
	int c=0;
	rep(ii,roop)
	{
		//rep(i,n)cout<<root[i];cout<<endl;
		bool isthrogh = true;
		rep(i,n-1)if(!ab[root[i]][root[i+1]])isthrogh=false;
		if(isthrogh)c++;
		next_permutation(root.begin(),root.end());
	}
	cout<<c<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
signed main() {
	string s;
	cin >> s;
 
	if (s.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (s.size() == 2) {
		if (s[0] == s[1]) cout << 1 << endl;
		else cout << 2 << endl;
		return 0;
	}
 
	int sz = s.size();
 
	s.push_back('A');
 
	int ans = 0;
	bool flag = true;
	for (int i = 0; i < s.size() - 1; i++) {
		if (i == sz - 2 && flag && s[i] == s[i + 1]) {
			ans++;
			break;
		}
		if (flag) {
			ans++;
			if (s[i + 1] == s[i]) flag = false;
		}
		else {
			ans++;
			i++;
			flag = true;
		}
		
	}
 
	
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
import java.util.*;

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

		int count = 1,x=1;
		while(x>0){
			x = scanner.nextInt();
			if(x==0){break;}
			System.out.println("Case "+count+ ": "+x);
			count++;
		}
	}
}

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

using namespace std;

typedef long long ll;

#define all(x) (x).begin(), (x).end()

const int N = 200200;
const int MAXN = 600600;

int ans = 59408656;
int n;

vector<int> on0[MAXN][4];
vector<int> on1[MAXN][4];
vector<int> on2[MAXN][4];
vector<int> on3[MAXN][4];

int Upd(vector<int> a, vector<int> b)
{
    int ans = 59408656;
    int j = 0;
    for (int i = 0; i < a.size(); i++)
    {
        while (j < b.size() && a[i] > b[j]) j++;
        if (j < b.size())
        {
            ans = min(ans, b[j] - a[i]);
        }
    }
    return ans;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        char dir;
        cin >> x >> y >> dir;
        x += N;
        int z;
        if (dir == 'U') z = 0;
        if (dir == 'R') z = 1;
        if (dir == 'D') z = 2;
        if (dir == 'L') z = 3;
        on0[x][z].push_back(y);
        on1[y][z].push_back(x);
        on2[x + y][z].push_back(x);
        on3[x - y][z].push_back(x);
    }
    for (int i = 0; i < MAXN; i++)
    {
        for (int z = 0; z < 4; z++)
        {
            sort(all(on0[i][z]));
            sort(all(on1[i][z]));
            sort(all(on2[i][z]));
            sort(all(on3[i][z]));
        }
        ans = min(ans, Upd(on0[i][0], on0[i][2]));
        ans = min(ans, Upd(on1[i][1], on1[i][3]));
        ans = min(ans, 2 * Upd(on3[i][0], on3[i][3]));
        ans = min(ans, 2 * Upd(on3[i][1], on3[i][2]));
        ans = min(ans, 2 * Upd(on2[i][1], on2[i][0]));
        ans = min(ans, 2 * Upd(on2[i][2], on2[i][3]));
    }
    if (ans == 59408656) cout << "SAFE";
    else cout << ans * 5;
}


Measured memory_bytes: 251232
#include <stdio.h>
 #include <stdlib.h>
 int main()
 {
   long long w,h,x,y;
   scanf("%lli%lli%lli%lli",&w,&h,&x,&y);
   if (w == 2*x && h == 2*y) {
     printf("%f %d", (double)(w*h)/2, 1);
   } else {
     printf("%f %d", (double)(w*h)/2, 0);
   }
   return 0;
 }


Measured memory_bytes: 1732
def comb_mod(n,r):
    mod = 10**9+7
    ans = 1
    for i in range(r):
        ans *= n-i
        ans %= mod
    for i in range(1,r+1):
        ans *= pow(i,mod-2,mod)
        ans %= mod
    return ans

def solve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-comb_mod(n,a)-comb_mod(n,b)-1
    ans %= mod
    return ans
print(solve())


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

const int n = 4;    
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    int t = 0;
    rep(i, 0, n) {
        int a; cin >> a;
        t += a;
    }
    cout << t / 60 << endl;
    cout << t % 60 << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <cstdlib>  //abs()で絶対値を取得する（整数）
#include <cmath>    //abs()かfabs()で絶対値を取得する（少数）
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 2e5 + 100;
ll h[N], dp[N];
int q[N], l = 1, r = 1;
int n;
ll c;

int main() {
    scanf("%d%lld", &n, &c);
    for (int i = 1; i <= n; i++)scanf("%lld", &h[i]);
    q[1] = 1;
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        while (l < r && (dp[q[l + 1]] + h[q[l + 1]] * h[q[l + 1]] - dp[q[l]] - h[q[l]] * h[q[l]]) <=
                        2 * h[i] * (h[q[l + 1]] - h[q[l]]))
            l++;
        dp[i] = dp[q[l]] + h[q[l]] * h[q[l]] - 2 * h[q[l]] * h[i] + h[i] * h[i] + c;
        while (l < r && (dp[q[r]] + h[q[r]] * h[q[r]] - dp[q[r - 1]] - h[q[r - 1]] * h[q[r - 1]]) * (h[i] - h[q[r]]) >=
                        (dp[i] + h[i] * h[i] - dp[q[r]] - h[q[r]] * h[q[r]]) * (h[q[r]] - h[q[r - 1]]))
            r--;
        q[++r] = i;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int l=s.size(),m=t.size();
  for(int i=l-m;i>=0;i--){
    bool a=true;
    for(int j=0;j<m;j++){
      if(s[i+j]!='?'&&s[i+j]!=t[j]){
        a=false;
        break;
      }
    }
    if(a){
      for(int j=0;j<m;j++){
        s[i+j]=t[j];
      }
      for(int j=0;j<l;j++){
        if(s[j]=='?')s[j]='a';
      }
      cout << s << endl;
      return 0;
    }
  }
  puts("UNRESTORABLE");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int32_t main()
    {
        IOS;
        ll k,l,n,m,q,m1,m2,flag=0,cnt,flag2,flag3,cnt2,sum=0,i,j;
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                sum+=a[i]*a[j];
            }
        }
        cout<<sum;




        return 0;

    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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;
}
int main(){
    string s;
    cin>>s;
    int len=s.size();
    int p=0;
    rep(i,len) if(s[i]=='p') p++;
    //gpgpgp...と出すとよさそう
    int ans=len/2;
    ans-=p;
    cout<<ans<<endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

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

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

int32_t main()
{
    FASTIO;

    int cnt = 0;
    ll n, d;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y <= d*d)
            cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main( ){
  int n;
  scanf("%d", &n);
  long long num[n], sum[n];
  for(int i = 0; i < n; i++){
    scanf("%lld", &num[i]);
    sum[i] = i == 0 ? num[i] : (sum[i - 1] % mod + num[i] % mod) % mod; 
  }
  long long ans = 0;
  for(int i = n - 1; i > 0; i--){
    ans = (ans % mod + (num[i] % mod * sum[i - 1] % mod) % mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 6952
#include <stdio.h>
int main(){

int i,j,H,W;

while(1){
scanf("%d %d",&H,&W);
if(H==0&&W==0)break;
for(i=0; i<H; i++){
for(j=0; j<W; j++){
if(i==0||i==H-1||j==0||j==W-1){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2016
# ABC054B - Template Matching
def main():
    N, M, *AB = open(0).read().split()
    N, M = int(N), int(M)
    A, B, lim = AB[:N], AB[N:], N - M + 1
    for i in range(lim):
        for j in range(lim):
            if [A[j + k][i : i + M] for k in range(M)] == B:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int main(){
	while(true){
		int n,l,p[20];
		char d[20];
		cin>>n>>l;
		if(n==0) break;
		rep(i,n) cin>>d[i]>>p[i];
		int cnt=n,lst=-1,id=0;
		bool out[20];
		rep(i,n) out[i]=0;
		for(int t=1;;t++){
			rep(i,n){
				if(out[i]) continue;
				if(d[i]=='R') p[i]++;
				else p[i]--;
			}
			rep(i,n) rep(j,i){
				if(out[i]||out[j]) continue;
				if(p[i]==p[j]) swap(d[i],d[j]);
			}
			rep(i,n) if(!out[i]&&(p[i]==0||p[i]==l)){
				out[i]=true;
				if(lst<t||p[i]==0) id=i;
				lst=t;
				cnt--;
			}
			if(cnt==0){
				cout<<t<<" "<<id+1<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1160
/*
Atcoder educational dp contest- problem c
Simple dp- O(N)
*/
#include<bits/stdc++.h>
using namespace std;
int satisfacoes[300000][3], dp[300000][3];
void calcula(int x){
    dp[x][0] = max(dp[x-1][1], dp[x-1][2])+ satisfacoes[x][0];
    dp[x][1] = max(dp[x-1][0], dp[x-1][2])+ satisfacoes[x][1];
    dp[x][2] = max(dp[x-1][1], dp[x-1][0])+ satisfacoes[x][2];
}
int main(){
    ios::sync_with_stdio(0);cin.tie(nullptr);
    int dias, temp1,temp2,temp3;
    cin>>dias;
    cin>>temp1>>temp2>>temp3;
    satisfacoes[0][0]=temp1;
    satisfacoes[0][1]=temp2;
    satisfacoes[0][2]=temp3;
    dp[0][0]=temp1;
    dp[0][1]=temp2;
    dp[0][2]=temp3;
    for(int i=1;i<dias;i++){
        cin>>temp1>>temp2>>temp3;
        satisfacoes[i][0]=temp1;
        satisfacoes[i][1]=temp2;
        satisfacoes[i][2]=temp3;
    }
    for(int i=1;i<dias;i++){
        calcula(i);
    }
    int resp = max(dp[dias-1][0], dp[dias-1][1]);
    resp = max(resp, dp[dias-1][2]);
    cout<<resp<<endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int MOD=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	ll N,K,r=0,mn=0,mx=0;
	cin >> N >> K;

	rep(i,K) {
		mn += i;
		mx += N-i;
	}

	rep(i,N-K+2) {
		r += mx-mn+1;
		r %= MOD;

		// cout << mn << " " << mx << endl;

		mx += N-K-i;
		mn += K+i;
	}

	cout << r << endl;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

INF = 10**18

def dfs(s):
    dist = [INF] * (N+1)
    dist[s] = 0
    stack = [s]
    while stack:
        v = stack.pop()
        for c in G[v]:
            if dist[c] == INF:
                dist[c] = dist[v] + 1
                stack.append(c)
    return dist

d1 = dfs(1)
v = max(range(1, N+1), key=lambda x: d1[x])
d2 = dfs(v)
diameter = max(d2[1:]) + 1
if (diameter - 2) % 3 == 0:
    print('Second')
else:
    print('First')

Measured memory_bytes: 95228