akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
//#define max(a,b) (a>b ? a : b)
//#define min(a,b) (a<b ? a : b)
 
const int MOD = 998244353;
const int INF = 1000002;
const double PI =4*atan(1);
const double eps = 1e-7;
const long long oo = 1e18;

int resolve(string S, string T){
  int s = (int)S.size(), t = (int)T.size();
  vector<vector<int>> dp(s+1, vector<int>(t+1, 0));
  rep(i, s+1) dp[i][0] = i;
  rep(i, t+1) dp[0][i] = i;

  for(int i=0; i<s; i++){
    for(int j=0; j<t; j++){
      dp[i+1][j+1] = min({dp[i+1][j]+1, dp[i][j+1]+1, dp[i][j]+(S[i]==T[j] ? 0 : 1)});
    }
  }
  return dp[s][t];
}

int main(){
  string S, T;
  cin >> S >> T;
  cout << resolve(S, T) << endl;
}


Measured memory_bytes: 6812
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define A_MAX 250
#define INVALID -2000000000

int main() {
    int m;
    int key;

    cin >> m;
    int* keys = new int[m];

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

    for (int i = 1; i < m+1; i++) {
        int parent = i / 2;
        int left = 2 * i;
        int right = 2 * i + 1;
        if (left > m) left = INVALID;
        if (right > m) right = INVALID;

        cout << "node " << i << ": key = " << keys[i-1] << ", ";
        if (i != 1) {
            cout << "parent key = " << keys[parent-1] << ", ";
        }
        if (left != INVALID) {
            cout << "left key = " << keys[left-1] << ", ";
        }
        if (right != INVALID) {
            cout << "right key = " << keys[right-1] << ", ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3044
#include<iostream>

using namespace std;

int main() {
	double A, B,N,X;
	cin >> N >> A >> B;
	X = N*A;
	if (X >= B) {
		cout << B << endl;
	}
	if (X < B) {
		cout << X <<endl;
	}
	return 0;
}

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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);

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

	if (N <= K) {
		cout << 1 << endl;
	}
	else {
		if ((N - K) % (K - 1) == 0) {
			cout << 1 + (N - K) / (K - 1) << endl;
		}
		else {
			cout << 1 + (N - K) / (K - 1) + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0)
    {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c)<<endl;
    return 0;
}

Measured memory_bytes: 256
A, B = map(int,input().split())

#偶数×偶数＝偶数、偶数×奇数＝偶数、奇数×奇数＝奇数。
#A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い

if A*B %2 == 0:
    print("No")

#if A*B %2 == 1:

else:
    print("Yes")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
int main()
{
    static const long double pi =3.1415926535897932384626433;
    long double A,B,H,N;
    cin >> A>>B>>H>>N;
    long double AX=A*cos(pi*(60*H+N)/360);
    long double AY=A*sin(pi*(60*H+N)/360);
    long double BX=B*cos(2*N*pi/60);
    long double BY=B*sin(2*N*pi/60);
    long double ans =sqrt((AX-BX)*(AX-BX)+(AY-BY)*(AY-BY));
    cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

     string s;cin>>s;
     int l=s.size();
     if(s[l-1]!='s')
     {
         s=s+'s';
         cout<<s;
     }
     else
     {
         cout<<s+"es";
     }
     


    

}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,m,x;
  cin >> n >> m >> x;

  vector<int> v(m,0);
  int sum[n+1];
  rep(i,n+1) sum[i] = 0;
  rep(i,m) {
    cin >> v[i];
    sum[v[i]]++;
  }

  int tmp1 = 0, tmp2 = 0;
  for (int i = 1; i <= x; ++i) {
    if (sum[i] > 0) {
      tmp1++;
    }
  }

  for (int i = n; i >= x; --i) {
    if (sum[i] > 0) {
      tmp2++;
    }
  }

  cout << min(tmp1,tmp2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 500000;
const long long MOD = 1e9 + 7;

int n, a, b;

long long inq(long long x, long long y)
{
    if (y == 0) return 1;
    long long l = inq(x, y / 2);
    if (y % 2) return l * l % MOD * x %MOD;
    return l * l % MOD;
}

long long cnk(long long n, long long k)
{
    if (k < 0) return 0;
    if (k == 0) return 1;
    return cnk(n, k - 1) * inq(k, MOD - 2) % MOD * (n - k + 1) % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    long long ans = inq(2, n);
    ans = (ans - 1 - cnk(n, a) - cnk(n, b) + MOD * MOD) % MOD;
    cout << ans;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long ans=0,min=1e9,a,cnt=0;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a<0)cnt++;
    a=abs(a);
    if(a<min)min=a;
    ans+=a;
  }
  if(cnt%2)ans-=2*min;
  cout << ans << endl;
  return 0;
}

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

int main(){
  long long n;
  //int temp;
  long long syoji=1000;
  long long kabun;//kabukin,
  //int kattaflag;
  cin >> n;
  vector<long long> a(n,0);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  kabun=0;
  for(int i=0;i<n-1;i++){
    long long stocks=0;
    if(a.at(i)<a.at(i+1)){//買う

      stocks=syoji/a.at(i);

    }
    syoji+=(a.at(i+1)-a.at(i))*stocks;

    //cout << i << ":" << kabukin << endl;
  }
  cout << syoji << endl;

  return(0);
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
static const int N = 100;

int main(int argc, char const *argv[])
{
    int M[N][N]; // 0 オリジンの隣接行列
    int n, u, k, v;

    cin >> n;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--; // 0 オリジンへ変換
        for(int j=0; j<k; j++){
            cin >> v;
            v--; // 0 オリジンに変換
            M[u][v] = 1; // u と v の間に辺を張る
        }
    }

    for(int i=0; i<n;i++){
        for(int j=0; j<n; j++){
            if(j) cout <<" ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,S,x=1;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  S=0;
  for(int i=0;i<N;i++){
    S+=x*a.at(i),x=-x;
  }
  cout<<S<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_trust_c() {
	ll X;
	ll ans = 0;

	cin >> X;

	ll a, b;
	a = X / 100;
	b = (ceil)((X % 100) / 5.0f);


	if (a < 1) {
		ans = 0;
	}
	else if (b <= a) {
		ans = 1;
	}
	else {
		ans = 0;
	}

	cout << ans << "\n";
}

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

	solve_trust_c();

	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from bisect import bisect_left, bisect_right

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

def make_pairs(S,x):
    # a + b <= x となるペアをなるべくたくさん作る
    # nペア（なるべくたくさん）作ったあと、1つ短い長さが残る
    seg = 0
    while S and S[-1] == x:
        S.pop()
        seg += 1
    i = bisect_right(S,x//2)
    lower = S[:i][::-1]; upper = S[i:]
    cand = []
    rest = []
    for b in upper[::-1]:
        while lower and lower[-1] + b <= x:
            cand.append(lower.pop())
        if cand:
            cand.pop()
            seg += 1
        else:
            rest.append(b)
    cand += lower[::-1]
    L = len(cand)
    q,r = divmod(L,2)
    if r:
        return seg + len(rest) + q, cand[0]
    else:
        seg += q
        if rest:
            return seg + len(rest) - 1, rest[-1]
        else:
            # 全部ペアになった
            return seg, 0

def solve(x):
    # 長さ x までの線分を許容した場合に、必要となる本数を返す
    dp = [0] * (N+1)
    temp = [[] for _ in range(N+1)] # 下から出てくる長さ
    for v in order[::-1]:
        p = parent[v]
        S = temp[v]
        S.sort()
        s, l = make_pairs(S,x)
        dp[v] += s        
        dp[p] += dp[v]
        temp[p].append(l + 1)
        if v == 1:
            return dp[1] if not l else dp[1] + 1

seg = solve(N + 10)
left = 0 # むり
right = N # できる
while left + 1 < right:
    x = (left + right) // 2
    if solve(x) == seg:
        right = x
    else:
        left = x
print(seg, right)

Measured memory_bytes: 145796
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃだめだよ！
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  bool a = false;
  bool b = false;
  bool c = false;
  bool d = false;
  bool e = false;
  bool f = false;
  bool g = false;
  bool h = false;
  int count = 0;
  rep(i, n) {
    int k = s[i];
    if (k <= 399)
      a = true;
    else if (k <= 799)
      b = true;
    else if (k <= 1199)
      c = true;
    else if (k <= 1599)
      d = true;
    else if (k <= 1999)
      e = true;
    else if (k <= 2399)
      f = true;
    else if (k <= 2799)
      g = true;
    else if (k <= 3199)
      h = true;
    else
      count++;
  }
  int total = 0;
  if (a) total++;
  if (b) total++;
  if (c) total++;
  if (d) total++;
  if (e) total++;
  if (f) total++;
  if (g) total++;
  if (h) total++;
  int ans = count + total;
  if (ans >= n) ans = n;
  if (total == 0)
    cout << 1 << " " << ans << endl;
  else if (count + total >= n)
    cout << total << " " << n << endl;
  else
    cout << total << " " << count + total << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define pa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define pv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define read(v) fl(i,0,v.size()-1) cin>>v[i];
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define vll vector<ll>
#define sll set<ll>
#define spll set<pll>
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define ff first
#define ss second
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    ll d,t,s;
    cin>>d>>t>>s;
    if(d <=t*s){
        cout<<"Yes"<<nl;
    }else cout<<"No"<<nl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<ll> factorList(ll x) {
    vector<ll> res;
    for (int p : primes) {
      while (x%p == 0) {
        res.push_back(p);
        x /= p;
      }
    }
    if (x != 1) res.push_back(x);
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<ll> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<ll,int>> res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

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

  vector<pair<ll,int>> fs;
  for (ll i = 2; i*i <= n; ++i) {
    int x = 0;
    while (n%i == 0) {
      n /= i;
      ++x;
    }
    fs.emplace_back(i,x);
  }
  if (n != 1) fs.emplace_back(n,1);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19756
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,x,i,j,ans = 1000000000000;cin >> n >> m >> x;bool ok;
  long long s,c[m],b = 0,p[n],u[n][m];
  for(i=0;i<n;i++){
    cin >> p[i];
    for(j=0;j<m;j++) cin >> u[i][j];
  }
  while(b<(1<<n)){
    s = 0;long long c[m] = {};ok = true;
    for(i=0;i<n;i++){
      if(b&(1<<i)){
        s += p[i];
        for(j=0;j<m;j++) c[j] += u[i][j];
      }
    }
    for(i=0;i<m;i++){
      if(c[i]<x){
        ok = false;break;
      }
    }
    if(ok) ans = min(ans,s);
    b++;
  }
  if(ans==1000000000000) ans = -1;
  cout << ans << "\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
	vector<int>v;
	int i,j,k,l,n;
   int a,b;
  
   cin>>a>>b>>k; 
   int ara[b];
   for(i=b,j=0;i>=1;i--)
   {
   	if(a%i==0&&b%i==0)
   	{
   		 
   	 ara[j]=i;
   	 j++;
	   }
	   
   }
    
   cout<<ara[k-1];
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int a=0;
  for(int i=0;i<S.size();i++){
    if(a==0){
      if(S[i]=='C'){a++;}
    }
    else if(a==1){
      if(S[i]=='F'){a++;}
    }
  }
  if(a==2){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    string S;
    cin >> S;
    S = '`' + S + '{';
    sort(S.begin(), S.end());
    int l = S.length();
    int ans = l;
    REP(i, l - 1){
        if (S[i+1] - S[i] > 1){
            ans = i;
            break;
        }
    }
    if (ans == l) cout << "None" << endl;
    else cout << char (S[ans] + 1) << endl;
    return 0;
}

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

using namespace std;

void solve() {
    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size(), ans = 1e9;
    for (int i = 0; i <= n-m; ++i) {
        int change = 0;
        for (int j = 0; j < m; ++j) {
            if (s[i+j] != t[j])
                ++change;
        }
        ans = min(ans, change);
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3616
fn main() {
    let scan = std::io::stdin();

    let mut line = String::new();

    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let W: i32 = vec[0].parse().unwrap_or(0);
    let H: i32 = vec[1].parse().unwrap_or(0);
    let x: i32 = vec[2].parse().unwrap_or(0);
    let y: i32 = vec[3].parse().unwrap_or(0);
    let r: i32 = vec[4].parse().unwrap_or(0);

    if &x >= &r && &x <= &(&W - &r) && &y >= &r && &y <= &(&H - &r) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5016
#include<bits/stdc++.h>
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<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     ordered_set s;
     s.insert(1);
     cout<<*s.find_by_order(1); //print kth smallest element
     cout<<s.order_of_key(3);  //print number of strictly smaller element of 3;
*/
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pi acos(-1)
#define bp __builtin_popcount
#define ll long long int
#define ld long double
#define endl '\n'
#define pii pair<ll , ll>
#define tii tuple<ll,ll,ll>
//aaaccess element of tuple ex. 3rd element(index 2) cout<< get<2>(tuppleName);

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define minq priority_queue <int, vector<int>, greater<int> >
#define maxQueue priority_queue<ll>
#define pb push_back
#define mx3(a,b,c) max(a,max(b,c))
#define pf push_front
#define ff first
#define ss second
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
const ll N = 1000005;
const ll M = 1e6 + 10;
const ll mod = 998244353;

ll power(ll x, ll y, ll p)
{
	ll res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return power(n, p - 2, p);
}
ll ncr(ll n, ll r, ll p)
{
	if (r == 0)
		return 1;
	int n1 = n;
	ll fac[n1 + 1];
	fac[0] = 1;
	for (int i = 1 ; i <= n; i++)
		fac[i] = fac[i - 1] * i % p;

	return (fac[n] * modinv(fac[r], p) % p *
	        modinv(fac[n - r], p) % p) % p;
}
/*vector<bool> prime(N, true);
void sieve()
{
	for (int i = 2; i <= sqrt(N); ++i) {
		if (prime[i]) {
			for (int j = i * i; j <= N; j += i) {
				prime[j] = false;
			}
		}
	}
}/*

/*int Prime[M];
void MinPrimeFactor()
{
	for (ll i = 1; i < M; i++) Prime[i] = i;
	for (int p = 2; p * p <= M; p++)
	{
		if (Prime[p] == p)
		{
			for (int i = 2 * p; i <= M; i += p)
			{
				Prime[i] = min(p, Prime[i]);
			}
		}
	}
}*/

/*vector<int> getFactorization(int x)
{
	vector<int> ret;
	while (x != 1)
	{
		ret.push_back(Prime[x]);
		x = x / Prime[x];
	}
	return ret;
}
*/
bool isPowerOfTwo(int x)
{
	return (x && !(x & (x - 1)));
}
int main()
{
	FAST;

	ll i, j, k, c = 0, a, b, m, n, l, r, t, sum = 0, x;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> k;
		if (i % 2 and k % 2)
			c++;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 3584
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 10 22:32:31 2019
//
package main

import (
	"fmt"
	"sort"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	for i := range arr {
		if i+1 < len(arr) {
			arr[i+1] += arr[i]
		}
	}

	ans := 1 << 60
	for i := 0; i < len(arr)-1; i++ {
		ans = min(ans, abs(arr[i]-(arr[len(arr)-1]-arr[i])))
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long k = Integer.parseInt(sc.next());
        long[] sum = new long[n+1];
        int[] a =new int[n];
        for(int i=0;i<n;i++){
            a[i] = Integer.parseInt(sc.next());
            sum[i+1] = sum[i] + a[i];
        }

        Map<Long,Integer> map = new HashMap<>();
        int right  = 0;
        long res = 0;
        for(int left = 0;right <= n;left++){
            while(right-left<k && right<=n){
                Long val = (sum[right]-right)%k;
                Integer count = map.get(val);
                if(count == null){
                    map.put(val,1);
                }else{
                    map.put(val,count+1);
                    res+=count;
                }
                right++;
            }
            Long val = (sum[left]-left)%k;
            Integer count = map.get(val);
            map.put(val,count-1);
        }

        System.out.println(res);
    }
    
}

Measured memory_bytes: 64444
#include <iostream>
using namespace std;
int main(void) {
	int n;
	int a;
	int b;
	int i;
	int p[100];
	int aq=0;
	int A=0;
	int B=0;

	int x;


	cin >> n;
	cin >> a;
	cin >> b;
	

	for (i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] <= a)
			aq++;
		else if ((p[i] >= (a + 1)) && (p[i] <= b))
			A++;
		else if (p[i] >= (b + 1))
			B++;

	}
	x = aq;
	if (x > A)
		x = A;
	if (x > B)
		x = B;

	
		
	cout << x;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[1202];
	cin>>s+1;
	int l=strlen(s+1);
	bool flag=true;
	for(int i=1;i<=l;i++)
	{
		if(s[i]=='C'&&flag)
			flag=false;
		if(s[i]=='F'&&!flag)
			return !printf("Yes");
	}
	return !printf("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, m, a,x=0;
    cin >> n >> m;
    vector<int> s,t;
    for (int i = 0; i < m; i++) {
        cin >> a;
        s.push_back(a);
    }
    sort(s.begin(), s.end());
    for (int i=0; i<s.size()-1; i++)
        t.push_back(s[i+1]-s[i]);
    sort(t.begin(), t.end());
    int k = t.size();
    for (int i = 0; i < min(n-1,k); i++) {
        x += t[t.size() - i - 1];
    }
    int ans = s[m - 1] - s[0] - x;
    cout << ans << endl;
}


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

int main(){
  long long N;
  cin >> N;
  long long ans = 0;
  long long x = 1;
  while(1){
    long long m = (N-x)/x;
    if(x>=m){
        break;
    }
    if((N-x)%x == 0){
        ans += m;
    }
    x++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
  int a[3],b[3]={0},s=0;
  while(cin>>a[0]>>a[1]>>a[2]){
    sort(a,a+3);
    if(a[0]+a[1]<=a[2])break;
    s++;
    if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])b[0]++;
    if(a[2]*a[2]<a[0]*a[0]+a[1]*a[1])b[1]++;
    if(a[2]*a[2]>a[0]*a[0]+a[1]*a[1])b[2]++;
  }
  cout<<s<<' '<<b[0]<<' '<<b[1]<<' '<<b[2]<<endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    string s;
    std::cin >> s;
    int c1=0,c2=0;
    rep(i,3){
        if(s[i]=='A')c1++;
        else c2++;
    }
    if(c1*c2)std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

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

using namespace std;
typedef long long int lli;

lli n, a[100005], b[100005], c[100005];

lli dp[100005][4];

lli solve(lli i, lli last){
    if(i == n) return dp[i][last] = 0;
    if(dp[i][last] != -1) return dp[i][last];
    lli ans1, ans2, ans3;
    ans1 = ans2 = ans3 = LONG_LONG_MIN;
    if(last != 1) ans1 = a[i] + solve(i+1, 1);
    if(last != 2) ans2 = b[i] + solve(i+1, 2);
    if(last != 3) ans3 = c[i] + solve(i+1, 3);

    return dp[i][last] = max(ans1, max(ans2, ans3));
}


int main(){
    //freopen("input.txt", "r", stdin);
    int T=1, cs=1;
    //scanf("%d", &T);
    while(T--){
        memset(dp, -1, sizeof(dp));
        scanf("%lld", &n);
        for(lli i=0; i<n; i++){
            scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);
        }
        printf("%lld\n", solve(0, 0));

    }

    return 0;
}

Measured memory_bytes: 11904
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            int n = 0;
            int last_n = 0;
            long ans = 0;
            bool up = true;

            if(s[0] == '>')
            {
                //up = false;
                ans = 1;
            }

            for (int i=0; i<s.Length; i++)
            {
                if(s[i] == '<')
                {
                    if (up)
                    {
                        n++;
                        ans += n;
                    }
                    else
                    {
                        n = 1;
                        ans += 1;
                        up = true;
                    }
                }
                else
                {
                    if (up)
                    {
                        last_n = n;
                        n = 0;
                        up = false;
                    }
                    else
                    {
                        n++;
                        if (last_n > n)
                        {
                            ans += n;
                        }
                        else
                        {
                            ans += n + 1;
                        }
                    }
                }
            }

            Console.WriteLine(ans);
            
        }
    
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 12896
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin >> N;
    bool flag = false, yes = true;
    cin>>K;
    rep(i,N-1){
        cin>>M;
        if(!flag){
            if(M == K-1){
                flag = true;
            }else if(M < K-1){
                yes = false;
                break;
            }
        }else{
            if(M > K){
                flag = false;
            }else if(M < K){
                yes = false;
                break;
            }
        }
        K = M;
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char a = sc.next().toCharArray()[0];
        char b = sc.next().toCharArray()[1];
        char c = sc.next().toCharArray()[2];
        String abc = String.valueOf(a) + String.valueOf(b) + String.valueOf(c);
        System.out.println(abc);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

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

  bool flg = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (i % 2 == 0 && S[i] == 'L')
    {
      flg = false;
      break;
    }
    if (i % 2 != 0 && S[i] == 'R')
    {
      flg = false;
      break;
    }
  }
  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int cs=0,cr=1;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R' && s[i+1]=='R')
        {
            cr++;
        }
        if(s[i]=='R')
        {
            cs++;
        }

    }
    if(cs==0)
    {
        cout<<"0";
    }
    else{
    cout<<cr;
    }
}


Measured memory_bytes: 3628
n = gets.to_i
a = gets.split.map(&:to_i)

if n == 0
    p a[0] == 1 ? 1 : -1
    exit
elsif a[0] == 1
    p -1
    exit
end

x = 1
s = a.sum
ans = 0
1.upto(n) do |i|
    if x * 2 < a[i]
        p -1
        exit
    end

    ans += x + a[i]
    s -= a[i]

    if x * 2 - a[i] <= s
        x = x * 2 - a[i]
    else
        x = s
    end

    #p [i, x, s, ans]
end

p ans

Measured memory_bytes: 20720
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second

#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("output.txt","w",stdout)
#define files files1;files2
#define files3 freopen("input.txt","r",stdin)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

#define mp make_pair
#define pb push_back

#define vi vector<int>
#define pii pair<int,int>

#define all(x) (x).begin(), (x).end()
#define fill(x) memset((x), 0, sizeof((x)))

#define ii input<int>()
#define ill input<ll>()
#define endl '\n'

using namespace std;

void bad(string mes = "impossible"){cout << mes;exit(0);}

template<typename T>
string bin(T x, int st = 2){
	string ans = "";
	while (x > 0){
	    ans += char('0' + x % st);
	    x /= st;
	}
	reverse(ans.begin(), ans.end());
	return ans.empty() ? "0" : ans;
}

template<typename T>
T dcm(string & s)
{
	T x = 0;
	for (int i = 0; i < s.size(); i++){
	    x = (x * 2) + (s[i] == '1');
	}
	return x;
}
template<typename T>
T input(){
	T ans = 0, m = 1;
	char c = ' ';
	while (c == ' ' || c == '\n')
	    c = getchar();
	if (c == '-')
	    m = -1, c = getchar();
	while (c >= '0' && c <= '9'){
	    ans = ans * 10 + int(c - '0'), c = getchar();
	}
	return ans * m;
}
template<typename T>
T binpow(T n, T s)
{
	if (s <= 0)
	    return 1LL;
	if (s % 2 == 0){
	    T b = binpow(n, s / 2);
	    return ( 1LL * b * b );
	} else {
	    return (1LL* binpow(n, s - 1) * n);
	}
}

const int inf = 2e9;
const double eps = 1e-9;
const int maxn = 4000, base = 1e9 + 7;
const ll llinf = 1e18;
int main(){
	//files1;
	int n=ii;
	vi d(n);
	for(auto& i:d)
		i=ii;
	int m=ii;
	vi t(m);
	for(auto& i:t)
		i=ii;
	sort(all(t));
	sort(all(d));
	int j=0;
	for(auto i:t){
		while(j<n&&d[j]!=i)
			j++;
		if(j==n){
			bad("NO");
		}
		j++;
	}
	bad("YES");

	return 0;
}


Measured memory_bytes: 1792
import itertools
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
per = list(itertools.permutations([i+1 for i in range(n)]))
ans = 0
for i in range(len(per)//n):
    # print(per[i])
    flug = True
    for j in range(n-1):
        way = list(per[i][j:j+2])
        # print(way, way[::-1], ab)
        if not((way in ab) or (way[::-1] in ab)):
            flug = False
            break
    if flug:
        ans += 1
print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

ll ex(ll k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i,n){
        cin >> p[i];
    }
    ll min=INF;
    ll ans = 0;
    REP(i,n){
        if(min>p[i]){
            min = p[i];
            ans += 1;
        } 
    }
    cout << ans << endl;
    
}


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

namespace CSharpSample01
{
    
    class Program
    {
        

        static void Main(string[] args)
        {
            string N = Console.ReadLine();

            for(int i = 0; i < N.Length; i++)
            {
                if(N[i] == '9')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }


            Console.WriteLine("No");
            
        }
    }
}

Measured memory_bytes: 13140
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {n:usize,a:usize}
    println! {"{}",
    if n % 500 <= a {
        "Yes"
    }
    else {
        "No"
    }
    }
}


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


vector<ll> col(100005);
vector<vector<P>> g(100005);


void dfs(int t, int p,int d){
//  cout<<"t"<<t<<"p"<<p<<"d"<<d<<endl;
  for(P T:g[t]){
    int to=T.first;
    if (to==p)continue;
    int dnow=d+T.second;
    if(dnow%2==0)col[to]=0;
    else col[to]=1;
    dfs(to,t,dnow);
  }
}

int main() {
  ll n;
  cin>>n;
  rep(i,n-1){
    ll u1,v1,w1;
    cin>>u1>>v1>>w1;
    u1--;v1--;
    g[u1].push_back(make_pair(v1,w1));
    g[v1].push_back(make_pair(u1,w1));
  }
  dfs(0,-1,0);
  rep(i,n)cout<<col[i]<<endl;
}


Measured memory_bytes: 12848
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main() {
	int A, B, C;
	int k;
	cin >> A >> B >> C;
	k = B / A;
	if (k >= C) cout << C << endl;
	else if (k < C)cout << k << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n-1);0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<< " (L"<<__LINE__<<")"<<endl;
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;

int main() {
    int n, m; cin >> n >> m;
    vector<vint> A(n, vint(n)), B(m, vint(m));
    rep(y, n) {
        string line; cin >> line;
        rep(x, n) A[x][y] = line[x] == '#' ? 1 : 0;
    }
    rep(y, m) {
        string line; cin >> line;
        rep(x, m) B[x][y] = line[x] == '#' ? 1 : 0;
    }
    rep(y0, n-m+1) {
        rep(x0, n-m+1) {
            if([&]() {
            rep(y, m) {
                rep(x, m) {
                    if(B[x][y] != A[x+x0][y+y0]) {
                        return false;
                    }
                }
            }
            return true;
            }()) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef tuple<int, int> seq; // tail, length
const int infty = 1e9+10;

int main () {
  int n;
  cin >> n;
  int a[100010];
  for (auto i=0; i<n; i++) {
    cin >> a[i];
  }
  set<seq> S;
  S.insert(make_tuple(infty, 100010));
  S.insert(make_tuple(-1, 0));
  for (auto i=0; i<n; i++) {
    auto it = S.lower_bound(make_tuple(a[i], -1));
    it--;
    seq temp = *it;
    get<0>(temp) = a[i];
    int tl = ++get<1>(temp);
    S.insert(temp);
    // cerr << "insert: " << get<0>(temp) << " " << get<1>(temp) << endl;
    it++; it++;
    while (it != S.end() && get<1>(*it) <= tl) {
      // cerr << "erase: " << get<0>(*it) << " " << get<1>(*it) << endl;
      S.erase(it++);
    }
  }
  auto it = S.end();
  it--; it--;
  cout << get<1>(*it) << endl;
}

Measured memory_bytes: 6268
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h =sc.nextInt(), w=sc.nextInt();
    String[][] pic= new String[h][w];
    for(int i=0; i<h; i++){
      pic[i]=sc.next().split("");
    }
    for(int i=0; i<=h+1; i++){
      for(int j=0; j<=w+1; j++){
        if(i==0 || i==h+1 || j==0 || j==w+1){
          System.out.print("#");
        }else{
          System.out.print(pic[i-1][j-1]);
        }
      }
      System.out.println("");
    }
  }
}

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

using lli = long long int;

using namespace std;

int main() {
    lli N, W;
    cin >> N >> W;

    std::vector<std::vector<lli>> dp(N, std::vector<lli>(W + 1, 0));

    std::vector<lli> w(N), v(N);
    for (lli i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    for (lli wi = 0; wi <= W; ++wi) {
        dp[0][wi] = wi - w[0] >= 0 ? v[0] : 0;
    }

    for (lli i = 1; i < N; ++i) {
        for (lli wi = 0; wi <= W; ++wi) {
            dp[i][wi] = 0;
            if (wi - w[i] >= 0) {
                dp[i][wi] = std::max(dp[i - 1][wi - w[i]] + v[i], dp[i][wi]);
            }
            dp[i][wi] = std::max(dp[i - 1][wi], dp[i][wi]);
        }
    }

    cout << dp[N - 1][W] << endl;

    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long
#define ld double

using namespace std;

const ll N = 2e5 + 5, M = N * 2;

int main()
{
    int n, m, xx, sum = 0;
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < m ; i++)
    {
        scanf("%d", &xx);
        sum += xx;
    }
    if(sum > n) puts("-1");
    else printf("%d\n", n - sum);
}


Measured memory_bytes: 3836
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = [set([a]) for a in LS2()]


def seg_func(x,y):
    return x | y

unit = set([])

class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = N
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)
    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(self.N):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR)


seg = SegTree(N,seg_func,unit)
seg.build(S)

Q = I()
for i in range(Q):
    a,b,c = LS()
    if a == '1':
        b = int(b)-1
        seg.set_val(b,set([c]))
    else:
        b,c = int(b)-1,int(c)-1
        print(len(seg.fold(b,c+1)))


Measured memory_bytes: 369412
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

class State{
public:
   int x1, y1, x2, y2;
   int cost;
};

int h, w;
bool mapData[50][50];
bool visited[50][50][50][50];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int ax, ay, bx, by;
int ans;

int bfs(){
   State u, v;
   u.x1 = ax-1;
   u.y1 = ay-1;
   u.x2 = bx-1;
   u.y2 = by-1;
   u.cost = 0;
   visited[u.y1][u.x1][u.y2][u.x2] = true;
   queue<State> Q;
   Q.push(u);
   while(!Q.empty()){
      u = Q.front();Q.pop();
      if(u.x1 == u.x2 && u.y1 == u.y2) return u.cost;
      for(int i=0;i<4;i++){
         int ty1 = u.y1 + dy[i];
         int tx1 = u.x1 + dx[i];
         int ty2 = u.y2 - dy[i];
         int tx2 = u.x2 - dx[i];
         if(ty1<0) ty1 = 0;
         if(tx1<0) tx1 = 0;
         if(ty2<0) ty2 = 0;
         if(tx2<0) tx2 = 0;
         if(ty1>=h) ty1 = h-1;
         if(tx1>=w) tx1 = w-1;
         if(ty2>=h) ty2 = h-1;
         if(tx2>=w) tx2 = w-1;
         if(mapData[ty1][tx1]){
            ty1 = u.y1;
            tx1 = u.x1;
         }
         if(mapData[ty2][tx2]){
            ty2 = u.y2;
            tx2 = u.x2;
         }
         if(visited[ty1][tx1][ty2][tx2]) continue;
         visited[ty1][tx1][ty2][tx2] = true;
         v.x1 = tx1;
         v.y1 = ty1;
         v.x2 = tx2;
         v.y2 = ty2;
         v.cost = u.cost+1;
         Q.push(v);
      }
   }
   return -1;
}

main(){
   while(cin >> w >> h && (h || w)){
      cin >> ax >> ay >> bx >> by;
      fill(visited[0][0][0], visited[50][0][0], false);
      for(int i=0;i<h;i++){
         for(int j=0;j<w;j++){
            cin >> mapData[i][j];
         }
      }
      ans = bfs();
      if(ans == -1) cout << "NA" << endl;
      else cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 0
lunluns = []

def dfs(n, cur):
    global lunluns
    lunluns.append(int(n))
    if cur > 8:
        return
    if n[-1] == '0':
        dfs(n+'0', cur+1)
        dfs(n+'1', cur+1)
    elif n[-1] == '9':
        dfs(n+'8', cur+1)
        dfs(n+'9', cur+1)
    else:
        last = int(n[-1])
        dfs(n + str(last-1), cur+1)
        dfs(n + str(last), cur+1)
        dfs(n + str(last+1), cur+1)

for i in range(1,10):
    dfs(str(i), 0)

K = int(input())
lunluns.sort()
print(lunluns[K-1])

Measured memory_bytes: 11276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{


    class Program
    {
        static void Main(string[] args)
        {
            //入力
            string[] msg = Console.ReadLine().Split(' ');
            int A = int.Parse(msg[0]);
            int B = int.Parse(msg[1]);
            int C = int.Parse(msg[2]);
            int D = int.Parse(msg[3]);

            //結果を出力
            Console.WriteLine(((A * B) > (C * D)) ? (A * B) : (C * D));
            Console.ReadLine();
        }


    }
}


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

int main(){
  string a;
  cin>>a;
  vector<int> b(a.size());
  int c=a.size();
  unsigned long long int d=0;
  for(int i=0;i<a.size();i++){
    b.at(i)=a.at(i)-'0';
  }
  for(int i=0;i<c;i++){
    for(int j=i;j<c;j++){
      if(i==j){
      d+=pow(10,c-j-1)*pow(2,j)*b.at(i);
      }
      else{
      d+=pow(10,c-j-1)*pow(2,j-1)*b.at(i);
      }
    }
  }
  cout<<d<<endl;
}


Measured memory_bytes: 512