akhauriyash/Code-Regression huggingface dataset:
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var ans = a[0];
  for(var i = 1; i < n; i++){
    ans = gcd(ans, a[i]);
  }
  return ans;
}

Measured memory_bytes: 30024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] strings = readLine();
		int N = Integer.parseInt(strings[0]);
		int[] A = new int[N];
		strings = readLine();
		for(int i=0;i<N;i++) {
			A[i]= Integer.parseInt(strings[i])-1;
		}
		int cnt = 0;
		for(int i=0;i<N;i++) {
			if(A[i]==cnt) {
				cnt++;
			}
		}
		if(cnt==0) {
			print(-1);
		}else {
			print(N-cnt);
		}
		
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC

	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

Measured memory_bytes: 51724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadInts();
            if (abc[0] == abc[1] && abc[0] != abc[2])
            {
                Console.WriteLine("Yes");
            }
            else if (abc[1] == abc[2] && abc[0] != abc[2])
            {
                Console.WriteLine("Yes");

            }
            else if (abc[0] == abc[2] && abc[0] != abc[1])
            {

                Console.WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	string s;
	cin >> s;
	int n = s.size();
	int t = 753;
	int d = 1000;
	string res;
	for (int i = 0; i + 2 < n; i++) {
				string ss = string(1, s[i]) + string(1, s[i + 1]) + string(1, s[i + 2]);
				if (abs(stoi(ss) - t) < d) {
					res = ss;
					d = abs(stoi(ss) - t);
				}
		
	}
	cout << d << endl;
}


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

int main(){
	int A, B;
	cin >> A;
	cin >> B;

	if (A - 2 * B < 0){
		cout << 0 << endl;
	}
	else{
		cout << A - 2 * B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int a, b;
    cin >>a >>b;
    if(0 <a){
        cout <<  " Positive ";
    }else{
        if(b>=0){
            cout  << " Zero ";

        }else{
            if((b-a)%2==0 ){
                cout << " Negative ";
            }else{
                cout << " Positive ";
            }
        }
    }

    
    return 0;
    
}

Measured memory_bytes: 256
S=input()
N=len(S)
Slis=[]
for i in range(N):
  Slis+=[int(S[i])]
T=[0 for i in range(N+1)]#T[i]はi桁より右側の数字


ten=1

for i in range(N):
  T[N-i-1]=(T[N-i]+ten*Slis[N-i-1])%2019
  ten=(ten*10)%2019

MOD=[0 for i in range(2019)]
for i in range(N+1):
  tmp=T[i]%2019
  MOD[tmp]+=1


  
ans=0

for i in range(2019):
  tmp=MOD[i]
  ans+=tmp*(tmp-1)//2
print(ans)


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

using namespace std;

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

	std::vector<int > v(n);

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

	vector<int >hash(n,0);

	hash[v[0]]=1;
	for(i=1;i<n;i++)
	{
		hash[v[i]]=hash[v[i]-1]+1;
	}
	int maxa=0;
	for(i=0;i<n;i++)
	{
		maxa=max(maxa,hash[i]);
	}
	cout<<n-maxa<<endl;

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,k;cin>>n>>k;
    vb b(n,false);
    rep(i,k){
        ll t;cin>>t;
        rep(j,t){
            ll a;cin>>a;
            b[a-1]=true;
        }
    }
    ll ans=0;
    rep(i,n)if(!b[i])ans++;
    out(ans);
}

Measured memory_bytes: 3628
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 100020
#define INF 100000000000000000ll
using namespace std;
LL read(){
	LL nm=0,fh=1; LL cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL n,x,F[3],G[3];
int main(){
	n=read(),G[1]=G[2]=-INF;
	while(n--){
		x=read(),F[0]=G[0]+x,F[1]=G[1]-x,F[2]=G[2]+x;
		if(x<0) F[2]=max(F[1],F[2]),F[1]=max(F[1],F[0]);
		F[0]=max(F[0],F[1]),F[1]=max(F[1],F[2]);
		G[0]=F[0],G[1]=F[1],G[2]=F[2];
	}
	printf("%lld\n",F[0]);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            int ans = 0;
            for (int i = 1; i <= N; i++) {
                if (String.valueOf(i).length() % 2 == 1) {
                    ans++;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
static ll dp[3030][3030];
const ll mod=998244353;
int main(void){
    ll n,s;
    cin>>n>>s;
    ll a[n];
    rep(0,i,n)cin>>a[i];
    rep(0,i,3030)rep(0,j,3030)dp[i][j]=0;
    dp[0][0]=1;
    rep(1,i,n+1){
        rep(0,j,s+1){
            //cout<<j-a[i]<<":";
            if(j>=a[i-1])dp[i][j]=(2*dp[i-1][j]+dp[i-1][j-a[i-1]])%mod;
            else dp[i][j]=2*dp[i-1][j]%mod;
            //cout<<dp[i][j]<<endl;
        }
    }
    cout<<dp[n][s];
}


Measured memory_bytes: 75356
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    string S;
    cin >> S;

    vector<int> alphas(26, 0);
    for (auto c: S) alphas[c - 'a']++;

    bool all = true;
    for (int i = 0; i < 26; i++) if (alphas[i] == 0) all = false;

    if (!all) {
        cout << S;
        for (int i = 0; i < 26; i++) {
            if (alphas[i] == 0) {
                cout << (char) (i + 'a');
                return 0;
            }
        }
    }

    if (S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1;
        return 0;
    }

    string nextS = S;
    next_permutation(nextS.begin(), nextS.end());
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == nextS[i]) cout << S[i];
        else {
            cout << nextS[i];
            return 0;
        }
    }

    return 0;
}





























































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

int main() {
	int n, k;
	cin >> n >> k;
	vector<string> s(n);
	vector<int> ch(26);

	for(int i = 0; i < 26; i++){
		ch[i] = 0;
	}
	
	for(int i = 0; i < n; i++){
		cin >> s[i];
		ch[s[i][0] - 'A']++;
	}
	
	sort(ch.begin(), ch.end());
	
	int ans = 0;
	int cnt = k;
	int cnt2 = 0;
	while(1){
		cnt = k;
		for(int i = 25; i >= 0; i--){
			if(ch[i] > 0){
				ch[i]--;
				cnt--;
				cnt2++;
			}
			if(cnt == 0){
				ans++;
				cnt = k;
				break;
			}
		}
		sort(ch.begin(), ch.end());
		if(cnt != k){
			break;
		}
		if(cnt2 == n){
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  int N_ = N;
  int sum = 0;
  while(N_ > 0) {
    sum += N_ % 10;
    N_ /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

typedef long long ll;

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

    int A,B,M;
    cin >> A >> B >> M;
    vector<int> a(A);
    int INF = 10000000;
    int mina = INF;
    for(int i=0;i<A;i++){
        cin >> a[i];
        mina = min(mina,a[i]);
    }
    int minb = INF;
    vector<int> b(B);
    for(int i=0;i<B;i++){
        cin >> b[i];
        minb = min(minb,b[i]);
    }
    int ans = mina + minb;
    vector<int> x(M),y(M),c(M);
    for(int i=0;i<M;i++) cin >> x[i] >> y[i] >> c[i];
    for(int i=0;i<M;i++){
        ans = min(a[x[i]-1]+b[y[i]-1]-c[i],ans);
    }
    cout << ans << endl;
    return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

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

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

ll N, M, S = 2;
double P;
vector<ll> A;
cpp_int comb[31];
def nHr() {
    comb[0] = 1;
    inc(i, 1, 30) comb[i] = comb[i - 1] * (N + i - 1) / i;
    inc(i, 1, 30) comb[i] %= MOD;
}

signed main() {
    ll M;
    cin >> N >> M;
    nHr();
    P = sqrt(M);
    while (M != 1) {
        A.push_back(0);
        if (M % S == 0) {
            while (M % S == 0) {
                M /= S;
                *(A.end() - 1) += 1;
            }
        } else if (S > P) {
            A.push_back(1);
            break;
        }
        S++;
    }
    cpp_int ANS = 1;
    rep(i, A.size()) {
        ANS *= comb[A[i]];
        ANS %= MOD;
    }
    cout << ANS << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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

#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define ll long long

int main()
{
    ios;

    string str;
    string str1;

    cin>>str;
    cin>>str1;

    int len = str.size() - str1.size() + 1;

    for(int i=0; i<len; i++)
    {
        i = str.find(str1,i);
        if(i != string::npos)
        {
            cout<<i<<endl;
        }
        else
        {
           return 0;
        }
    }

    return 0;
}



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

int main(){
  int n;
  cin >> n;
  
  if(n==111){n=999;}
  else if(n==119){n=991;}
  else if(n==191){n=919;}
  else if(n==911){n=199;}
  else if(n==199){n=911;}
  else if(n==919){n=191;}
  else if(n==991){n=119;}
  else{n=111;}
  
  cout << n;
  
  return 0;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1);
  rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];

  vector<int> ans(n, 0);
  repr(i, n - 1) { 
    FOR(j, i, n - 1) {
      if (ans[i] < s[j]) ans[i] = s[j];
      else {
        if (ans[i] % f[j] != 0) ans[i] += f[j] - (ans[i] % f[j]);
      }
      ans[i] += c[j];
    }
  }

  rep(i, n) cout << ans[i] << endl;






  
  return 0;
}

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

#define rep(i, k) for (ll i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n, ans = 0;
    cin >> n;
    int min_p = INT_MAX;
    rep(i, n) {
        int temp;
        cin >> temp;
        if (min_p >= temp) {
            min_p = temp;
            ++ans;
        }
    }
    cout << ans;
}

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

int main (void) {
    string S;
    string T = "";
    string strlist[4] = {"dream", "dreamer", "erase", "eraser"};
    string result = "NO";

    cin >> S;

    string tmp_str = "";
    for (int i = (int)S.size()-1; i >= 0; --i) {

        tmp_str = S[i] + tmp_str;

        if (tmp_str.size() == 5) {
            if ((tmp_str == "dream") || (tmp_str == "erase")) {
                T = tmp_str + T;
                tmp_str = "";
            }
        } else if (tmp_str.size() == 6) {
            if (tmp_str == "eraser") {
                T = tmp_str + T;
                tmp_str = "";
            } 
        } else if (tmp_str.size() == 7) {
            if (tmp_str == "dreamer") {
                T = tmp_str + T;
                tmp_str = "";
            }
        }
    }

    if (S == T) {
        result = "YES";
    }

    cout << result << endl;

}


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

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

  if(s[0] == 'A'){
    int cnt = 0;
    for(int i=2; i<s.size() - 1; ++i){
      if(s[i] == 'C') ++cnt;
    }
    if(cnt == 1){
      bool f = false;
      for(int i=1; i<s.size(); ++i){
	if(s[i] != 'C'){
	  if(!(s[i] >= 'a' && s[i] <= 'z')) break;
	}
	if(i == s.size()-1) f = true;
      }

      if(f){
	cout << "AC" << endl;
	return 0;
      }
    }
  }

  cout << "WA" << endl;
  return 0;
}

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

using namespace std;


#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,a) FOR(i,0,a)
#define ROF(i,a,b) for(int i = (b)-1; i >=(a); i--)
#define RREP(i,a) ROF(i,0,a)
#define MOD 1000000007
#define pb push_back
#define um unordered_map
#define us unordered_set
#define rs resize
#define LSB(x) ((x)&(-x))
typedef long long ll;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<bool> vb; typedef vector<vb> vvb;
typedef vector<ll> vll; typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> djki;
typedef priority_queue<pll, vector<pll>, greater<pll>> djkll;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usll;

vi h;
vi dp;
int n, k;
int solve(int r) {
    if(r == 1) return 0;
    if(r == 2) return abs(h[2] - h[1]);
    if(dp[r] != -1) return dp[r];
    int best = INT_MAX;
    for(int i = 1; i <= k && r - i >= 1; i++) {
        best = min(best, abs(h[r] - h[r - i]) + solve(r - i));
    }
    return dp[r] = best;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    h.resize(n + 1, 0);
    dp.resize(n + 1, -1);
    REP(i, n) cin >> h[i + 1];
    cout << solve(n) << endl;
    return 0;
}

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

int main(){
  
  int n;
  cin>>n;
  
  if (n==1){
    cout<<"Hello World"<<endl;
  }
  
  else {
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
  
  
}
  













Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  if(y <= 2019 && m <= 4 && d <= 30) {
    printf("Heisei\n");
  } else {
    printf("TBD\n");
  }
}

Measured memory_bytes: 128
table = list(map(int,input().split()))
 
for i in range(2,0,-1):
    k = 0
    while k < i:
        if table[k] > table[k+1]:
            table[k],table[k+1] = table[k+1],table[k]
        k += 1;
 
 
print(table[0],table[1],table[2])


Measured memory_bytes: 5600
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long H,W,h,w,r,c;
    cin>>H>>W>>h>>w;
    r=abs(H-h);
    c=abs(W-w);
    cout<<r*c<<endl;

}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

bool comp(const P& f, const P& s) {
  return f.first < s.first;
}

int main() {
  int N;
  cin >> N;
  vector<P> students(N);
  for (int i=0; i<N; ++i) {
    cin >> students[i].first;
    students[i].second = i+1;
  }
  sort(students.begin(), students.end());

  for (int i=0; i<N; ++i) {
    if (0<i) cout << " ";
    cout << students[i].second;
  }
  cout << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    int s = 0, m = 0, l = 0;
    rep(i, N){
        if(P[i] <= A) s++;
        else if(P[i] <= B) m++;
        else l++;
    }
    cout << min(s, min(m, l)) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
    int b = sc.nextInt();  // input Integer
    int c = sc.nextInt();  // input Integer
    
    double x=(double) a / c;
    if ( b>= x){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

//    String a = sc.next();  // input String
  }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> arr(n), dp(n, INT_MAX);
    for (auto &i: arr)
        cin >> i;
    dp[0] = 0;
    for (int i=1; i<n; i++)
        for (int j = max(0, i-k); j<i;  j++)
            dp[i] = min(dp[i], dp[j]+abs(arr[i]-arr[j]));
    cout << dp.back() << "\n";
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int MAXN = 100001;
int N, M;

int parent[MAXN];
int rnk[MAXN];
int A[MAXN], B[MAXN];
LL answer[MAXN];

void initialize(){
    for (int i = 1; i <= N; ++i){
        parent[i] = i;
        rnk[i] = 1;
    }
}

int find(int u){
    return parent[u] == u ? u : find(parent[u]);
}

bool same(int u, int v){
    return find(u) == find(v);
}

bool unite(int u, int v){
    int uf = find(u); int vf = find(v);
    if (uf != vf){
        if (rnk[uf] < rnk[vf]){
            swap(uf, vf);
        }
        rnk[uf] += rnk[vf];
        parent[vf] = uf;
    }
    return uf != vf;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> M;
    for (int i = 0; i < M; ++i){
        cin >> A[i] >> B[i];
    }
    reverse(A, A+M); reverse(B, B+M);
    answer[0] = (LL)N * (N-1) / 2;
    initialize();
    for (int i = 0; i < M; ++i){
        answer[i+1] = answer[i];
        if (not same(A[i], B[i])){
            answer[i+1] -= (LL)rnk[find(A[i])] * rnk[find(B[i])];
        }
        unite(A[i], B[i]);
    }

    for(int i = M - 1; i >= 0; --i){
        cout << answer[i] << '\n';
    }
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code


int main(int argc, char const* argv[])
{
	LL n,x;
	cin >> n >> x;
	n++;
	VL p_all(n);
	VL height(n);
	p_all[0] = 1;
	height[0] = 1;
	for (int i = 1; i < n; i++) {
		p_all[i] = 2*p_all[i-1] + 1;
		height[i] = 2*height[i-1] + 3;
	}
	LL ans = 0;
	for (int l = n-1; l >= 1; l--) {
		if (x >= height[l] - 1) {
			ans += p_all[l-1] * 2 + 1;
			break;
		}
		else if (x >= height[l] / 2) {
			ans += p_all[l-1] + ((x > height[l] / 2) ? 1 : 0);
			x -= 1 + height[l-1] + ((x > height[l] / 2) ? 1 : 0);
		}
		else {
			x--;
		}
		if (x <= 0) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(n)
l= len(s)-1
ans = 0
temp = [[0]*10 for i in range(10)] ##temp[i][j]::一桁目i,最期の桁jの数
for k in range(1,n+1):

    temp[int(str(k)[0])][int(str(k)[-1])] +=1
for i in range(10):
    for j in range(10):
        ans+=temp[i][j]*temp[j][i]
print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	static int modAns = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a = a1;
		int count = 0;
		int bucket[] = new int[1000010];
		while(true) {
			count ++;
			if(bucket[a] > 0) { break; }
			bucket[a] ++;
			a = func(a);
		}
		System.out.println(count);
	}

	public static int func(int n) {
		return n % 2 == 0 ? n / 2 : n * 3 + 1;
	}
}

Measured memory_bytes: 25812
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n - 2):
    if (p[i] < p[i + 1] and p[i + 1] < p[i + 2]) or (p[i] > p[i + 1] and p[i + 1] > p[i + 2]):
        c += 1
print(c)

Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline

DIV = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))

# ある数の取り得る状態は以下
# (1)部分集合Pに含まれない
# (2)部分集合Pに含まれ、和に使われている
# (3)部分集合Pに含まれ、和に使われていない

# dp[k] = 総和がkになっている場合の数
dp = [0] * (S + 1)
dp[0] = 1

for i in range(N):
  nextline = [0] * (S + 1)
  for k in range(S, -1, -1):
    # (1)部分集合Pに含まれない
    # (3)部分集合Pに含まれ、和に使われていない
    nextline[k] += dp[k] * 2
    nextline[k] %= DIV

    # (2)部分集合Pに含まれ、和に使われている
    if k + A[i] <= S:
      nextline[k + A[i]] += dp[k]
      nextline[k + A[i]] %= DIV
    
  dp = nextline

print(dp[-1])


Measured memory_bytes: 74260
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
const ll MOD = 1000000007; int ans =0;
int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i]; a[i]--;
    }ll h = 1;
    while ((1LL << h) < k) h++;
    vector<vector<int>> doubling(h, vector<int>(n));
    rep(i, n) doubling[0][i] = a[i];
    rep(i, h -1) {
        rep(j, n) {
            doubling[i + 1][j] = doubling[i][doubling[i][j]];
        }
    }
    int now = 0;
    for (ll i = 0; k > 0; i++) {
        if (k & 1) now = doubling[i][now];
        k = k >> 1;
    }cout << now + 1 << endl;
}

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

int main(){
  int N;
  cin>>N;
  string ans = "No";
  int maxD = N/7;
  int maxC = N/4;
  int nedan = 0;
  for(int i = 0;i<=maxD;i++){
    if(ans=="Yes")break;
    for(int j = 0;j<=maxC;j++){
      if(ans=="Yes")break;
      if(i*7+j*4==N){
        ans="Yes";
      }
    }
  }



  cout<<ans<<endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m,k, p, q, w, h, ans, cnt, dp[2000][2000], sum, a[200000], b[200000];
string str[10000];
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	deque<string>ss;
	rep(i, n) {
		cin >> str[i];
		rep(j, str[i].size() - 1) {
			if (str[i][j] == 'A'&&str[i][j + 1] == 'B')
				ans++;
		}
		if (str[i][0] == 'B'&&str[i][str[i].size() - 1] == 'A')p++;
		else if (str[i][0] == 'B')q++;
		else if (str[i][str[i].size() - 1] == 'A')k++;
	}
	ans += max((LL)0,p - 1);
	if (p > 0) {
		if (q > 0)ans += 1, q--;
		if (k > 0)ans += 1, k--;
	}
	ans += min(q, k);
	cout << ans << endl;
	return 0;
}


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

int main(){
  int x,n;
  cin >> x >> n;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    x-=a;
  }
  if(x<=0)puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int num[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> num[i];
	}


	for (int i = 0; i < 2; i++)
	{
		int k = i;
		for(int j = i + 1; j < 3 ; j++)
		{
			if (num[k] > num[j])
			{
				k = j;
			}
		}
		if (k != i)
		{
			int t = num[k];
			num[k] = num[i];
			num[i] = t;
		}
	}
	
	for (int i = 0; i < 3; i++)
	{
		if (i != 2)
			cout << num[i] << " ";
		else
			cout << num[i] << endl;
	}

	return 0;
}


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

int main(){
  ll N, K, loop_count;
  map<ll, ll> chokudai;
  cin >> N >> K;
  ll current = 1;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  for (int i = 0; i < K; i++){
    // 現在地に来たことがあれば最後に来た時のカウントと現在のカウントを比較、計算
    if (chokudai.count(current)){
      loop_count = i - chokudai.at(current);
      K = i + ((K-i) % loop_count);
      if (i == K) break; 
    }
    // 現在地に来たことがなければ今のカウントを保持
    else chokudai[current] = i;
    
    current = A.at(current - 1);
  }
  cout << current << endl;
}


Measured memory_bytes: 14884
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
    cin.tie(0) ;
    ios::sync_with_stdio(false) ;
    
    int T;
    cin >> T;
    while (T--) {
        u64 N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j,ans1,ans2,ans3,ans4;
	for(;;){
		cin>>H>>W;
		if(W==0&&H==0)
			break;
		for(i=1;i<=H;i++){
			ans1=i/2*2;
			for(j=1;j<=W;j++){
				ans2=j/2*2;
				if((i==ans1)!=(j==ans2)){
					cout<<'.';
				}else{
					cout<<'#';
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int h, w, k; cin >> h >> w >> k;
	vector<vector<int>> b(h, vector<int>(w)), c;
	rep(i, h)
	{
		string x; cin >> x;
		rep(j, w)
		{
			int y = x[j] - '0';
			b[i][j] = y;
		}
	}
	ll mx = 0;
	rep(x, h)rep(y, w)
	{
		ll res = 0;
		int cnt = 0;
		c = b;
		c[x][y] = 0;
		for (int z = x; z > 0; --z)
		{
			c[z][y] = b[z - 1][y];
		}
		c[0][y] = 0;
		while (true)
		{
			bool change = false;
			int tmp = 0;
			rep(i, h)
			{
				int j = 0;
				while (j <= w - k)
				{
					int l = j + 1;
					int now = c[i][j];
					if (now == 0)
					{
						j = l;
						continue;
					}
					while (l < w&&c[i][l] == now)++l;
					if (l - j >= k)
					{
						change = true;
						for (int m = j; m < l; ++m)
						{
							tmp += now;
							c[i][m] = 0;
						}
					}
					j = l;
				}
			}
			if (!change)break;
			rep(j, w)rrep(i, h)
			{
				int l = i;
				while (l >= 0 && c[l][j] == 0)--l;
				if (l < 0)c[i][j] = 0;
				else swap(c[i][j], c[l][j]);
			}
			res += powl(2, cnt)*tmp;
			++cnt;
		}
		mx = max(mx, res);
	}
	cout << mx << endl;
}

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

vector<string> bbb;

void aaa(string x,ll y,ll n,ll m){
    if(y<n){
        FOR(i,x[y]-'0',(m-1)){
            aaa(x+(char)('0'+i),y+1,n,m);
        }
    }else{
        bbb.push_back(x);
    }
}

int main(void){
    ll n,m,q;
    cin >> n >> m >> q;
    vll a(q),b(q),c(q),d(q);
    REP(i,q){
        cin >> a[i] >> b[i]>> c[i] >> d[i];
    }

    aaa("0",0,n,m);

    ll ans0 = 0;
    for(auto itr=bbb.begin(); itr != bbb.end(); itr++){
        //cout << (*itr) << endl;
        ll ans = 0;
        REP(i,q){
            if((*itr)[b[i]-1]-(*itr)[a[i]-1]==c[i]) ans += d[i];
        }
        ans0 = max(ans0,ans);
    }

    cout << ans0 << endl;
}

Measured memory_bytes: 7464
import collections
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

H, W, *S = open(0).read().split()
H, W = [int(_) for _ in [H, W]]
A = []
B = []
C = []
for i in range(H * W):
    x, y = divmod(i, W)
    if S[x][y] == '.':
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            nx, ny = x + dx, y + dy
            if not (0 <= nx < H and 0 <= ny < W):
                continue
            if S[nx][ny] == '.':
                A += [i]
                B += [nx * W + ny]
                C += [1]
F = floyd_warshall(csr_matrix((C, (A, B)), shape=(H*W, H*W)))
print(int(np.max(F[F!=np.inf])))


Measured memory_bytes: 40264
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define li long long int
#define ld long double
#define F first
#define S second
//const li M = 1000000007;
#define ld long double
li dx[]={-1,1,0,0};
li dy[]={0,0,-1,1};

int main()
{
	char ch; cin>>ch;
	if(ch<'a')
	cout<<"A";
	else
	cout<<"a";

}



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

int main(){
  int n;
  cin >>n;
  vector<int> v(n),c(n);
  for(int i=0;i<n;i++) cin >>v[i];
  for(int i=0;i<n;i++) cin >>c[i];

  vector<int> r(n);
  for(int i=0;i<n;i++) r[i] = v[i]-c[i];

  int ans=0;
  for(int i=0;i<n;i++){
    if(r[i] > 0) ans += r[i];
  }

  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string c;
	long long n;
	cin>>c>>n;
	if(n==1)
		cout<<c[0]<<endl;
	else{
		for(int i=0;i<c.length();i++){
			if(c[i]=='1' && i+1>=n){
				cout<<c[i]<<endl;
				break;
			}
			else if(c[i]!='1' ){
				cout<<c[i]<<endl;
				break;
			}
		}
	}
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N, M;
VI ts, ps, xs;
VI ans;

void solve() {
	rep (i, M) {
		int num = ps[i] - 1;
		int sum = 0;
		rep (j, N) {
			if (j == num) {
				sum += xs[i];
			} else {
				sum += ts[j];
			}
		}
		ans.pb(sum);
	}
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N;
	rep (i, N) {
		int t;
		cin >> t;
		ts.pb(t);
	}
	cin >> M;
	rep (i, M) {
		int p, x;
		cin >> p >> x;
		ps.pb(p);
		xs.pb(x);
	}
	solve();
	for (int a : ans) {
		cout << a << endl;
	}
	return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
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<typename T, typename U> class GridGraph{
    typedef tuple<int,int,U> TP;
public:
    int h, w;
    vector<vector<T>> grid;
    vector<int> dx, dy;
    vector<vector<int>> depth_x, depth_y;

    GridGraph(int h, int w) : h(h), w(w), grid(h+2, vector<T>(w+2, '#')),
    depth_x(h+2, vector<int>(w+2, 0)), depth_y(h+2, vector<int>(w+2,0)){
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> grid[i][j];
            }
        }
        dx = {1, 0, -1, 0, 1, 1, -1, -1};
        dy = {0, 1, 0, -1, 1, -1, 1, -1};
    }

    bool out(int x, int y){
        return (x < 0 || x > h+1 || y < 0 || y > w+1);
    }

    int dfs_x(int x, int y, int dx, int cost){
        if(out(x, y) || depth_x[x][y] > 0 || grid[x][y] == '#'){
            return cost;
        }
        return depth_x[x][y] = dfs_x(x + dx, y, dx, cost + 1);
    }

    int dfs_y(int x, int y, int dy, int cost){
        if(out(x, y) || depth_y[x][y] > 0 || grid[x][y] == '#'){
            return cost;
        }
        return depth_y[x][y] = dfs_y(x, y + dy, dy, cost + 1);
    }

    void solve(){
        REP(i, h+2){
            REP(j, w+2){
                if(grid[i][j] == '#'){
                    dfs_x(i-1, j, -1, 0);
                    dfs_x(i+1, j, 1, 0);
                    dfs_y(i, j-1, -1, 0);
                    dfs_y(i, j+1, 1, 0);
                }
            }
        }
        int ans = 0;
        REP(i, h+2){
            REP(j, w+2){
                //cerr << depth_x[i][j];
                chmax(ans, depth_x[i][j] + depth_y[i][j] - 1);
            }
            //cerr<<endl;
        }
        cout << ans << endl;
    }




};

signed main(){
    int h, w;
    cin >> h >> w;

    GridGraph<char,int> G(h, w);
    G.solve();

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    int ans = n;
    rep(i, n - 1) {
        if(s[i] == s[i + 1]) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9576
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

s = inputSL()

if s[0][-1] == s[1][0] and s[1][-1]==s[2][0]:
  print("YES")
else:
  print("NO")

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

int main(){
	int t;
	while(true){
		cin >> t;
		if(t == 0)break;
		int n;
		int ice[10] = {};
		for(int i = 0; i < t; i++){
			cin >> n;
			ice[n]++;
		}
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < ice[i]; j++){
				cout << '*';
			}
			if(!ice[i])cout << '-' << endl;
			else cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
import java.util.*;

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

        int n = 50;
        long[] ans = new long[n];

        long quo = k / n;
        int rem = (int)(k % n);

        for(int i=0; i<n; i++){
            ans[i] = n-1+quo;
        }

        for(int i=0; i<rem; i++){
            ans[i] += n - (rem-1);
        }
        for(int i=rem; i<n; i++){
            ans[i] -= rem;
        }

        System.out.println(n);
        for(int i=0; i<n-1; i++){
            System.out.print(ans[i] + " ");
        }
        System.out.println(ans[n-1]);
    }
}

Measured memory_bytes: 23764
// 参考: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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")
    };
}

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! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
}

fn main() {
    input! {
        k: i64,
        ab: [i64;2],
    };

    let tmp = (ab[1] / k) * k;

    if tmp <= ab[1] && tmp >= ab[0] {
        println!("OK");
    } else {
        println!("NG");
    }
}


Measured memory_bytes: 2136
import numpy as np
A, B, H, M = map(int, input().split())

m_ang = (360 / 60) * M
h_ang = (360 / (12 * 60)) * (60 * H + M)
deg = abs(m_ang - h_ang)
if deg > 180:
    deg = 360 - deg
deg = np.deg2rad(deg)

C2 = A**2 + B**2 - 2*A*B*np.cos(deg)
print(np.sqrt(C2))


Measured memory_bytes: 27136