akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 2020;

int H, W;
int grid1[MAX][MAX], grid2[MAX][MAX];

void print() {
    REP (h, H) {
        REP (w, W) cout << grid1[h][w] << " ";
        cout << "\n";
    }
    cout << endl;
    REP (h, H) {
        REP (w, W) cout << grid2[h][w] << " ";
        cout << "\n";
    }
}

int solve() {
    REP (h, H) {
        FOR (w, 1, W) if (grid1[h][w] != -1) grid1[h][w] = grid1[h][w-1] + 1;
        REP (w, W) grid1[h][w]++;
        REPR (w, W) if (grid1[h][w] != 0) grid1[h][w] = max(grid1[h][w], grid1[h][w+1]);
    }
    REP (w, W) {
        FOR (h, 1, H) if (grid2[h][w] != -1) grid2[h][w] = grid2[h-1][w] + 1;
        REP (h, H) grid2[h][w]++;
        REPR (h, H) if (grid2[h][w] != 0) grid2[h][w] = max(grid2[h][w], grid2[h+1][w]);
    }
    int ans = 0;
    REP (h, H) REP (w, W) {
        ans = max(ans, grid1[h][w] + grid2[h][w] - 1);
    }
    return ans;
}

int main() {
    cin >> H >> W;
    REP (h, H) {
        string S; cin >> S;
        REP (w, W) if (S[w] == '#') {
            grid1[h][w] = grid2[h][w] = -1;
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 32000
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

th = sum(A)/(4 * M)

##print(threshhold)

c = 0
for val in A:
    if val >= th:
    ##print(val)
        c += 1

if M > c:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
main(){
int N,M;
cin>>N>>M;
vector<int>D(N);
vector<int>C(M);
for(int i=0;i<N;i++){cin>>D[i];}
for(int i=0;i<M;i++){cin>>C[i];}
vector<vector<int> >dp(M+1,vector<int>(N+1,(1<<30)));dp[0][0]=0;
for(int i=1;i<=M;i++){for(int j=0;j<=N;j++){
if (j == 0){dp[i][j] = dp[i - 1][j];}
else{dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + C[i - 1] * D[j - 1]);}}}
cout << dp[M][N] << endl;
return 0;}

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

char nth_letter(int64_t n){
    assert(n >= 0 && n <= 25);
    return "abcdefghijklmnopqrstuvwxyz"[n];
}

int main() {
  int64_t N;
  cin >> N;
  int l = 0;//文字列の長さ
  int64_t M = N;//コピーした！
  string s;//こたえ
  
  for(int i = 1; i < 100; i++){//100もあれば十分
    M -= pow(26LL, i);
    l++;
    if(M <= 0){
      M += pow(26LL, i);
      M--;
      break;
    }
  }
  
  for(int i = 0; i < l; i++){
    int64_t r;
    r = M % 26;
    char v = nth_letter(r);
    s += v;
    M /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    for (int n; cin >> n && n;) {
        VI s(n); cin >> s;
        cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << "\n";
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sum /= 2;

    for(int i = 0; i < n-1;i+=2) {
        sum -= a[i];
    }
    b[n-1] = sum*2;

    for(int i = n-2; i >= 0; i--) {
        b[i] = (a[i] - b[i+1]/2)*2;
    }
    rep(i, n) {
        cout << b[i];
        if(i != n-1)
            cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2944
mod = 10 ** 9 + 7
s = input()
n = len(s)

dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1
# dp[i][j] : i 文字目まで見たとき j 余る個数

for i, ss in enumerate(s, 1):
    # print(ss)
    p = pow(10, n - i, 13)
    if ss == '?':
        for c in '0123456789':
            to_add = (int(c) * p) % 13
            for r in range(13):
                dp[i][(r + to_add) % 13] += dp[i - 1][r]
                dp[i][(r + to_add) % 13] %= mod
    else:
        to_add = (int(ss) * p) % 13
        for r in range(13):
            dp[i][(r + to_add) % 13] += dp[i - 1][r]
            dp[i][(r + to_add) % 13] %= mod
print(dp[n][5])
# print(*dp[n], sep='\n')
# print(s)


Measured memory_bytes: 62428
#include<bits/stdc++.h>
#define YOU setprecision
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s;
  cin >>a>>b;
  if(b%a==0) cout <<a+b<<'\n';
  else cout <<b-a<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef complex<double> base;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const bool debug=false;
const ll RP=6974266;
const ll mod=1003176017;
const ll RP1=6720670;
const ll mod1=1e9+696969;

ll n, ans, cnt[30], cv[37], cv1[37];
string s[222222];
vector<ll> VEC[222222];
vector<ll> VVEC[222222];
set<ll> ST;
unordered_map<ll, int> S[26];

int main(void)
{
	fio; ll i, j, k, rv; cin>>n;
	for(i=0 ; i<26 ; i++) cv[i]=rng()%mod;
	for(i=0 ; i<26 ; i++) cv1[i]=rng()%mod1;
	for(i=1 ; i<=n ; i++) cin>>s[i];
	for(i=1 ; i<=n ; i++)
	{
		VEC[i].resize(s[i].length()+1);
		VVEC[i].resize(s[i].length()+1);
		VEC[i][0]=0; VVEC[i][0]=0; ll st=0, st1=0;
		for(j=s[i].length()-1, rv=1 ; j>=0 ; j--, rv++)
		{
			st=(st*RP+cv[s[i][j]-'a'])%mod;
			st1=(st1*RP1+cv1[s[i][j]-'a'])%mod;
			VEC[i][rv]=st; VVEC[i][rv]=st1;
		}
		ST.insert(VEC[i][s[i].length()-1]*mod1+VVEC[i][s[i].length()-1]);
	}
	for(i=1 ; i<=n ; i++)
	{
		for(j=0 ; j<26 ; j++) cnt[j]=0;
		for(j=0 ; j<s[i].length() ; j++) cnt[s[i][j]-'a']++;
		ll st=0;
		if(ST.count(st))
			for(j=0 ; j<26 ; j++) if(cnt[j]) S[j][st]++;
		for(j=s[i].length()-1, rv=1 ; j>=0 ; j--, rv++)
		{
			st=VEC[i][rv]*mod1+VVEC[i][rv]; cnt[s[i][j]-'a']--;
			if(ST.count(st))
				for(k=0 ; k<26 ; k++) if(cnt[k]) S[k][st]++;
		}
	}
	for(i=1 ; i<=n ; i++)
		ans+=S[s[i][0]-'a'][VEC[i][s[i].length()-1]*mod1+VVEC[i][s[i].length()-1]];
	cout<<ans-n; return 0;
}

Measured memory_bytes: 69676
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

// 約数列挙
vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> div = calc_divisor(M);
    
    // M の約数 d であって、d * N <= M となる最大の d を求める
    long long res = 1;
    for (auto d : div) {
        if (d * N <= M) res = max(res, d);
    }

    cout << res << endl;
}

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

int a[10001];

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

	}
	for(int i=0;i<n;i++){
		g=g+a[i];
	}
	int m1=a[0];
	int m2=a[0];
	for(int i=1;i<n;i++){
		if(m1<a[i]){
			m1=a[i];
		}
		if(m2>a[i]){
			m2=a[i];
		}
	}
	cout<<m2<<" "<<m1<<" "<<g<<endl;
	return 0;
}

Measured memory_bytes: 3164
N, X = map(int, input().split())

flag = False
result = [-1,-1,-1]
for i in range(min(N, X // 10**4) + 1):
  for j in range(min(N-i, (X-10**4*i) // 5000) + 1):
    if (X - 10**4*i - 5000*j) // 1000 == N - i - j:
      result = (i,j,N-i-j)
      flag = True
      break
  if flag:
    break
print(*result)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(0)==5 && a.at(1)==5 && a.at(2)==7)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[]save = new String[N];
		long sum = 0;
		HashMap<String, Integer> countView = new HashMap<String, Integer>();
		for(int i = 0; i < N; i++) {
			String tmp = sc.next();
			char tmpArray[] = tmp.toCharArray();
			Arrays.sort(tmpArray);
			String afterSort = new String(tmpArray);
			//HashMapを使う
			if(countView.containsKey(afterSort)) {
				int oldValue = countView.get(afterSort);
				int newValue = oldValue + 1;
				countView.put(afterSort, newValue);
				sum += newValue;
			}else {
				countView.put(afterSort, 0);
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 55884
import java.util.*;
import java.io.*;

public class Main {

  private static void solve() {
    boolean[][] m = new boolean[4][4];

    for (int i = 0; i < 3; i++) {
      int a = nextInt() - 1;
      int b = nextInt() - 1;

      m[a][b] = m[b][a] = true;
    }

    int[] a = {0, 1, 2, 3};
    Set<int[]> perms = new HashSet<>();
    perms(a, new int[4], new boolean[4], 0, perms);

    boolean found = false;
    for (int[] perm : perms) {
      boolean[] touched = new boolean[4];
      for (int i = 0; i < perm.length - 1; i++) {
        if (m[perm[i]][perm[i + 1]]) {
          touched[perm[i]] = true;
          touched[perm[i + 1]] = true;
        } else {
          break;
        }
      }

      boolean temp = true;
      for (boolean b : touched) {
        temp &= b;
      }

      if (temp) {
        found = true;
        break;
      }
    }

    System.out.println(found ? "YES" : "NO");
  }

  private static void perms(int[] a, int[] x, boolean[] used, int i, Set<int[]> set) {
    if (i == x.length) {
      int[] copy = Arrays.copyOf(x, x.length);
      set.add(copy);
    } else {
      for (int j = 0; j < used.length; j++) {
        if (!used[j]) {
          used[j] = true;
          x[i] = a[j];
          perms(a, x, used, i + 1, set);
          used[j] = false;
        }
      }
    }
  }


    private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    ll ans = 1e18;
    ll val = 0,sum = 0;
    for(int i=0;i<N;i++){
        ll nsum = sum+A[i];
        if(i%2==0){
            if(nsum<=0){
                val += 1-nsum;
                nsum = 1;
            }
        }else{
            if(nsum>=0){
                val += nsum+1;
                nsum = -1;
            }
        }
        sum = nsum;
    }
    ans = min(ans,val);
    val = 0,sum = 0;
    for(int i=0;i<N;i++){
        ll nsum = sum+A[i];
        if(i%2==0){
            if(nsum>=0){
                val += nsum+1;
                nsum = -1;
            }
        }else{
            if(nsum<=0){
                val += 1-nsum;
                nsum = 1;
            }
        }
        sum = nsum;
    }
    ans = min(ans,val);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
vector<vector<int>> adj;
vector<vector<int>> dp;
int dfs(int r,int par=-1,int color=1){
    if(dp[r][color]!=-1)return dp[r][color];
    long long ans = 1LL;
    for(auto c:adj[r]){
        if(c==par)continue;
        int temp = dfs(c,r,1);
        if(color==1)temp+=dfs(c,r,0);
        ans*=temp;
        ans%=m;
    }
    dp[r][color] = ans;
    return dp[r][color];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,u,v;
    cin>>n;
    adj.assign(n,vector<int>());
    dp.assign(n,vector<int>(2,-1));
    for(int i=0;i<n-1;i++){
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    cout<<(dfs(0)+dfs(0,-1,0))%m<<"\n";
    return 0;
}

Measured memory_bytes: 19584
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll H, W;
	cin >> H >> W;
	auto coins = make_vec_nd(0, W, H);
	auto print = [](ll a, ll b, ll c, ll d) {
		cout << a << " " << b << " " << c << " " << d << endl;
	};
	rep(h,0,H) {
		rep(w,0,W) {
			ll coin;
			cin >> coin;
			coins[w][h] = coin;
		}
	}
	struct Op {
		ll a;
		ll b;
		ll c;
		ll d;
	};
	vector<Op> ops;
	rep(x,0,W) {
		rep(y,0,H-1) {
			if (coins[x][y] % 2 == 1) {
				ops.push_back({y+1, x+1, y+2, x+1});
				coins[x][y]--;
				coins[x][y+1]++;
			}
		}
		if (x != W-1) {
			if (coins[x][H-1] % 2 == 1) {
				ops.push_back({H, x+1, H, x+2});
				coins[x][H-1]--;
				coins[x+1][H-1]++;
			}
		}
	}
	cout << ops.size() << endl;
	for (Op op : ops) {
		print(op.a, op.b, op.c, op.d);
	}
}


Measured memory_bytes: 7408
x,y = input().split()
x = int(x)
y = int(y)
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if (x in a and y in a) | (x in b and y in b) | (x in c and y in c):
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k;
    cin>>n>>k;
    ll ans=0;

    vector<ll> h(n);
    for(ll i=0; i<n; i++) {
        cin>>h[i];
    }
    sort(h.begin(), h.end(),greater<ll>());
    for(ll i=k; i<n; i++) {
        ans += h[i];
        dbg(ans);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1792
x, y, a, b, c = gets.split.map(&:to_i)
p = gets.split.map(&:to_i).sort.reverse
q = gets.split.map(&:to_i).sort.reverse
r = gets.split.map(&:to_i)
pqr = (p.slice(0, x) + q.slice(0, y) + r).sort.reverse
puts pqr.slice(0, x + y).inject(:+)


Measured memory_bytes: 31568
A = list(map(int, input().strip().split()))

flg = 0
rslt = -10000000000000000000000000
for x in [A[0],A[1]]:
    for y in [A[2],A[3]]:
        flg = x*y
        
        rslt = max(rslt,flg)
        
        

print(rslt)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E, F, G;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    D = i%10;
    E = i/10000%10;
    F = i/10%10;
    G = i/1000%10;
    if (D == E && F == G )
      C++;
  }
  cout << C << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int a,b,c;
	int cnt;
	scanf("%d %d %d",&a,&b,&c);
	for(a;a<=b;a++){
		if(c%a==0){
		cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
/*
#ifdef JUDGE
#include <fstream>
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
#include <iostream>
using std::cin;
using std::cout;
#endif
*/
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
long double eps = 1.0E-14;
long long MOD = 1000000007;
/*
bool comparator(const MyStruct& lhs, const MyStruct& rhs) {
   return lhs.key < rhs.key;
}
*/
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull t,T;
	cin >> t;
    ull val = 100ULL;
    ull l = 0;
    double tmp = 100.0;
    for(;;) {
        tmp *= 1.01;
        val = tmp;
        tmp = val;
        l ++;
        if (val >= t) {
            cout << l << endl;
            return 0;
        }
    }
}

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

const long INF = LONG_MAX / 2;

int main(){
    long N, W; cin >> N >> W;
    vector<vector<long>> dp(N+1, vector<long>(100001, INF));
    dp[0][0] = 0;
    for(int i=0; i<N; i++){
        long w, v; cin >> w >> v;
        for(int j=0; j<100001; j++){
            if(j-v>=0) dp[i+1][j] = min(dp[i][j], dp[i][j-v] + w);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    long result = 0;
    for(int j=0; j<100001; j++){
        if(dp[N][j] <= W ) result = j;
    }
    cout << result << endl;
}

Measured memory_bytes: 80384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  char c;
  cin >> c;

  if(c == 'A') cout << 'T' << newl;
  if(c == 'T') cout << 'A' << newl;
  if(c == 'G') cout << 'C' << newl;
  if(c == 'C') cout << 'G' << newl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
int main(){
	int N;
	cin>>N;
	ll sum=0;
	for(int i=1;i<=N;++i)
	if(i%3!=0&&i%5!=0)sum+=i;
	cout<<sum;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int l,r,d; cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;++i)if(i%d==0)++ans;
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const long double EPS = 1e-9;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<char> &o) {
    string a;
    in >> a;
    for (char c : a) o.insert(c);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


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

    vector<ll> l(n), r(n);
    rep(i, n) cin >> l[i] >> r[i];

    sort(l.begin(), l.end());
    sort(r.begin(), r.end());

    auto get_med = [&](vector<ll> &v) -> ll {
        if (n % 2 == 0) {
            int i = n / 2;
            int j = i - 1;
            return v[i] + v[j];
        } else {
            int i = n / 2;
            return v[i] + v[i];
        }
    };

    ll lm = get_med(l), rm = get_med(r);


    if (n % 2 == 0) {
        ll ans = rm - lm + 1;
        cout << ans << endl;
    } else {
        ll ans = rm - lm + 2;
        cout << ans / 2 << endl;
    }

}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main(){
	 pair<string,int> v[1002];
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	string s;
	cin>>s;
	int ans=0;
	for(i=0;i<n;i++)
		if(v[i].first==s)
		{
			break;
		}
	for(i=i+1;i<n;i++)
		ans+=v[i].second;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void main()
{
  int a,b,c,d,e,i,count=0;
  char s[100];
  scanf("%s",s);
  a=strlen(s);
  b=a-1;
  c=b/2;
  d=a+3;
  e=d/2;
  for(i=0;i<c;i++)
  {
    if(s[i]==s[e-1+i])
    count++;
  }
if(count==c)
  printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, std::string S, std::string T){
  REP(x, N) {
    cout << S.at(x) << T.at(x);
  }
  cout << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(N, S, T);
}


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

//約数列挙 計算量O(sqrt(n))
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> ans1 = divisor(n - 1);
  vector<ll> ans2 = divisor(n);
  //n-1の約数のうち1は含めない
  ll ans = ans1.size()-1;
  for (int i = 1; i < ans2.size(); i++){
    ll num = n;
    while(num % ans2[i] == 0){
      num /= ans2[i];
    }
    if(num % ans2[i] == 1) ans++;
  }
  cout << ans << endl;
}

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

int n;
int f[101][10];
int p[101][11];

int dfs(int j, int c[], int x){
    if(j == 10){
        int ans = 0;
        if(x == 0){
            ans -= 1000000000;
        }
        for(int i = 0; i < n; i++){
            ans += p[i][c[i]];
        }
        return ans;
    }
    else{
        int cc[101];
        for(int i = 0; i < n; i++){
            cc[i] = c[i];
            if(f[i][j] == 1){
                cc[i]++;
            }
        }
        return max(dfs(j + 1, c, x), dfs(j + 1, cc, x + 1));
    }
}

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }
    int c[101] {0};
    cout << dfs(0, c, 0) << endl;
}

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

bool f(vector<queue<pair<int, int>>>(&que), vector<int>(&x), int idx, int start, vector<bool>(&is_calculated))
{
    bool ret = false;
    if (!is_calculated[idx])
    {
        is_calculated[idx] = true;
        x[idx] = start;
    }
    while (que[idx].size() > 0)
    {
        int next_idx = que[idx].front().first;
        int next_val = que[idx].front().second + start;
        que[idx].pop();
        if (is_calculated[next_idx])
        {
            if (x[next_idx] != next_val)
            {
                ret = true;
            }
        }
        else
        {
            ret |= f(que, x, next_idx, next_val, is_calculated);
        }
    }
    return ret;
}

int main()
{
    int N, M;
    cin >> N >> M;
    int L;
    int R;
    int D;
    vector<queue<pair<int, int>>> que(N + 1);
    for (int i = 0; i < M; i++)
    {
        cin >> L >> R >> D;
        que[L].push(make_pair(R, D));
        que[R].push(make_pair(L, -D));
    }

    vector<bool> is_calculated(N + 1, 0);
    vector<int> x(N + 1, 0);
    string ans = "Yes";
    for (int i = 1; i <= N; i++)
    {
        if (f(que, x, i, 0, is_calculated))
        {
            ans = "No";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 76800
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    if(a<=8 && b<=8){
        cout << "Yay!" << endl;
        return 0;
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	int x=a.size(),y=b.size();
	if(x>y){
		puts("GREATER");
		return 0;
	}
	else if(x<y){
		puts("LESS");
		return 0;
	}
	else{
		for(int i=0;i<x;i++){
			if(a[i]>b[i]){
				puts("GREATER");
				return 0;
			}
			else if(a[i]<b[i]){
				puts("LESS");
				return 0;
			}
		}
		puts("EQUAL");
	}
	return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
ans = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if k>=0 and 10000*i+5000*j+1000*k==Y:
            ans=[i,j,k]
            print(*ans)
            exit()
print(*ans)

Measured memory_bytes: 3060
n = int(input())

if bin(n).count('1') == 1:
    print('No')
else:
    print('Yes')
    print('1 2')
    print('2 3')
    print('3 {0}'.format(n + 1))
    print('{0} {1}'.format(n + 1, n + 2))
    print('{0} {1}'.format(n + 2, n + 3))

    if n >= 5:
        if n % 2 == 1:
            for i in range(4, n + 1):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
        else:
            for i in range(4, n):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
            print('{0} {1}'.format(n - 1, n))
            print('{0} {1}'.format((n - 1) ^ 1 ^ n, n * 2))


Measured memory_bytes: 5208
#include <cstdio>
#include <algorithm>

int N, M, p;
int d[30000];

int f(){
    int res = 1001001001, i, j;
    for(i=0;d[i]<p;i++);
    for(j=i;d[j]<p+N;j++);
    // printf("%d, %d\n", i, j);
    for(;i<j;i++){
        res = std::min(res,
                       p+N-d[i] + (j-i==M?0:d[i+M-1]-d[i]));
        // printf("%d: %d %d\n", i, p+N-d[i], (j-i==M?0:d[i+M-1]-d[i]));
    }

    return res;
}

int main(){
    scanf("%d %d %d", &N, &M, &p);

    for(int i=0;i<M;i++){
        scanf("%d", d+i);
        d[i+M] = d[i] + N;
        d[i+2*M] = d[i] + 2*N;
    }

    std::sort(d, d+3*M);

    int res = f();
    p = N-1-p;
    for(int i=0;i<3*M;i++){
        d[i] = N-1-d[i]%N + d[i]/N*N;
    }
    for(int i=0;i<3;i++){
        std::reverse(d+i*M, d+(i+1)*M);
    }
    res = std::min(res, f());

    printf("%d\n", res * 100);
}

Measured memory_bytes: 1140
gets;gets;x=!p,!0;x.map{|a|x.map{|b|c,d,*k=a,b;$_.chop.chars{|i|d^=c^=i<?p;k<<c^=d};c^a||d^b||k.map{|x|$>.<<x ??S:?W}+exit}};p~0

Measured memory_bytes: 6388
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define istream ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define uint unsigned int
#define mod 1000000007
#define vec vector<int>
#define twod vector<vector<int>>
#define mp make_pair
#define pbc push_back
#define all(a) a.begin(),a.end()
#define debug1(x)                cout<<#x<<"="<<x<<endl;
#define debug2(x,y)              cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z)            cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define debugarray(arr,j,n)      for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";};

int32_t main()
{
     int n;
     cin>>n;
     vec arr;
     for(int i=0;i<n;i++){
          int temp;
          cin>>temp;
          arr.push_back(temp);
     }
     vec dp(n,INT_MAX);
     dp[0]=0;
     for(int i=0;i<n-1;i++){
          dp[i+1] = min(dp[i+1],dp[i] + abs(arr[i+1]-arr[i]));
          if(i != n-2)
               dp[i+2] = min(dp[i+2],dp[i] + abs(arr[i+2]-arr[i]));
     }
     cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 5012
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    constexpr int N = 100010;
    vector<int> prime;
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }
    int n; cin >> n;

    cout << *lower_bound(ALL(prime),n) << endl;;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long ans = 0;
		int[] D = new int[N];
		for(int i = 0;i < N;i++) {
			D[i] = scn.nextInt();
		}

		for(int i = 0;i < N;i++) {
			for(int j = i+1;j < N;j++) {
				ans += D[i] * D[j];
			}
		}
		System.out.println(ans);
	}

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n;

map<char, vector<char>> mp = {
   {'1', {'.', ',', '!', '?', ' '}},
   {'2', {'a', 'b', 'c'}},
   {'3', {'d', 'e', 'f'}},
   {'4', {'g', 'h', 'i'}},
   {'5', {'j', 'k', 'l'}},
   {'6', {'m', 'n', 'o'}},
   {'7', {'p', 'q', 'r', 's'}},
   {'8', {'t', 'u', 'v'}},
   {'9', {'w', 'x', 'y', 'z'}},
};

void solve() {
   debug(mp['1'][0])
   debug(mp['1'][1])
   debug(mp['1'][2])

   exit(0);
}

int main() {
   // solve();
   cin >> n;
   while (n--) {
      string s;
      cin >> s;

      string ans = "";
      int size = s.size();
      for (int i = 0; i < size; i++) {
         if (s[i] == '0') continue;
         int cnt = 0;
         int idx = i;
         repp (j, i, size) {
            if (s[i] != s[j]) break;
            idx = j;
            cnt++;
         }
         int tSize = mp[s[i]].size();
         // printf("mp[%c][%d], %d\n", s[i], cnt%tSize, tSize);
         cnt--;
         if (cnt >= 0) {
            char c = mp[s[i]][cnt % tSize];
            ans += c;
         }
         i = idx;
      }

      cout << ans << endl;
   }

   return 0;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;
	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'T' || S[i] == 'G') {
			tmp++;
		}
		else {
			if (tmp > ans) {
				ans = tmp;
				tmp = 0;
			}
		}
	}
	if (tmp > ans)ans = tmp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import heapq

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
for i in range(n):
  if arr2[i]!=arr1[i]:
    heapq.heappush(q,(-arr2[i],i))
cnt=0
while q:
  val,pos=heapq.heappop(q)
  val*=-1
  diff=arr2[pos-1]+arr2[(pos+1)%n]
  move,tmp=divmod(val-arr1[pos],diff)
  if move==0:
    break
  cnt+=move
  tmp+=arr1[pos]
  arr2[pos]=tmp
  if tmp!=arr1[pos]:
    heapq.heappush(q,(-tmp,pos))
for i in range(n):
  if arr1[i]!=arr2[i]:
    print(-1)
    break
else:
  print(cnt)

Measured memory_bytes: 122140
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
const int INF = 1000000;
const int N = 10;

int main() {
  // ifstream cin("../test.txt");
  int n;
  while (true) {
    cin >> n;
    if (!n) break;
    int dp[N][N];
    // 初期化
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dp[i][j] = INF; // i=jは？
      }
    }
    int a, b, c;
    while (n--) {
      cin >> a >> b >> c;
      dp[a][b] = c;
      dp[b][a] = c;
    }
    // ワーシャルフロイド法
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          if (dp[i][j] > dp[i][k] + dp[k][j])
            dp[i][j] = dp[i][k] + dp[k][j];
        }
      }
    }
    // 町ごとに通勤時間の総和を計算
    int sum[N];
    for (int i = 0; i < N; i++) {
      sum[i] = 0;
      for (int j = 0; j < N; j++) {
        if (i != j && dp[i][j] != INF) {
          sum[i] += dp[i][j];
        }
      }
    }
    // 通勤時間が最小の町を求める
    int ans_i = 0;
    for (int i = 1; i < N; i++) {
      if (sum[i] < sum[ans_i] && sum[i] != 0)
        ans_i = i;
    }
    // 出力
    cout << ans_i << " " << sum[ans_i] << endl;
  }
}

Measured memory_bytes: 1160
s=input()
s1=[]
s2=[]
ans=[]
a=0
a1=0
for i in range(len(s)):
    if s[i]=="\\":
        s1.append(i)
    elif s[i]=="/" and s1:
        i2=s1[-1]
        a1=i-i2
        a+=a1
        while s2 and s2[-1][0]>i2:
            a1+=s2[-1][1]
            s2.pop()
        s2.append([i2,a1])
        s1.pop()


n=len(s2)
for j in range(n):
  ans.append(s2[j][1])
print(a)
print(n,*(ans))


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

int main()
{
  long long N;

  cin >> N;

  vector<long long> A(N);

  for (long long i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  long long max_num = 0;

  long long sum = 0;

  for (long long i = 0; i < N; i++)
  {
    if (A.at(i) >= max_num)
    {
      max_num = A.at(i);
    }
    else
    {
      sum += max_num - A.at(i);
    }
  }

  cout << sum << endl;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    string s,t;
    cin >> s >> t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());

    int ans = 0;

    if(s.at(0) < t.at(t.size()-1)){
        ans = 1;
    }

    if(s.size() < t.size() && s == t.substr(t.size()-s.size(),s.size())){
        ans = 1;
    }

    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      String work = scanner.nextLine();
      if (work.equals("0")) {
        break;
      }
      String works[] = work.split(" ");
      int s = 0;
      int oc = 0;
      for (int ii = 0; ii < works.length; ii++) {
        int w = Integer.parseInt(works[ii]);
        if (2 <= w && w <= 9) {
          s += w;
        } else if (10 <= w && w <= 13) {
          s += 10;
        } else {
          oc++;
        }
      }

      for (int ii = 0; ii < oc; ii++) {
        if (ii == oc - 1) {
          s += s + 11 <= 21 ? 11 : 1;
        } else {
          s++;
        }
      }

      if (s > 21) {
        s = 0;
      }
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  bool loop = true;
  // pが元から単調増加数列の場合を除く
  for (int i=0; i<N-1; i++) {
    if (p[i]>p[i+1]) {
      loop = false;
      break;
    }
  }
  if (!loop) {
    for (int i=0; i<N; i++) {
      for (int j=i+1; j<N; j++) {
        swap(p[i], p[j]);
        for (int k=0; k<N-1; k++) {
          if (p[k]>p[k+1]) {
            swap(p[i], p[j]);
            loop = true;
            break;
          }
          loop = false;
        }
        if (!loop) break;
      }
      if (!loop) break;
    }
    if (!loop) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstdint>

int main() {
	std::int64_t s;
	std::cin >> s;

	std::set<int> set;
	set.insert(s);

	for (int i = 2; ; ++i) {
		s = (s % 2 == 0 ? s / 2 : 3 * s + 1);

		if (set.count(s)) {
			std::cout << i << std::endl;
			break;
		}

		set.insert(s);
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count=0;
    int maxx=0;

    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
            count++;
        }
        else{
            count = 0;
            continue;
        }
        maxx=max(count,maxx);
        
    }
    cout << maxx <<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    vector<int> v(5);
    for(int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if(x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
N,X=map(int,input().split())
L=list(map(int,input().split()))
xs=[]
x=0
time=1
for i in range(N):
  x+=L[i]
  xs.append(x)
for i in range(N):
  if xs[i]<=X:
    time+=1
  else:
    break
print(time)


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int d,g;
    cin>>d>>g;
    V c(11),p(11);
    rep(i,d)cin>>p[i]>>c[i];
    //bit全探索+greedy
    //bonusをとるか取らないかを全探索
    //まだ足りなければとらんかったやつでgreedy
    int ans=INF;
    for(int bit=0;bit<(1<<d);bit++){
        int sum=0;
        int cnt=0;
        //bonusとるやつ
        rep(i,d){
            int bonus=c[i];
            int pos_P=p[i];
            if(bit&(1<<i)){
                sum+=100*(i+1)*pos_P+bonus;
                cnt+=pos_P;
            }
        }
        if(sum>=g)ans=min(ans,cnt);
        //bonusとらんやつ
        else{
            rrep(i,d){//greedy
                if(bit&(1<<i))continue;
                int pos_P=p[i];
                rep(j,pos_P){
                    if(sum>=g)break;
                    sum+=100*(i+1);
                    cnt++;
                }
            }
            ans=min(ans,cnt);
        }
    }
    cout<<ans<<endl;
}

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

int n,m,a[501][501],f[501][501][2];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);
	vector<pair<pair<int,int>,pair<int,int>>> ans;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			if(i==n && j==m)continue;
			if(a[i][j]&1)
			{
				if(i==n)
				{
					a[i][j+1]+=1;
					ans.push_back(make_pair(make_pair(i,j),make_pair(i,j+1)));
				}
				else
				{
					a[i+1][j]+=1;
					ans.push_back(make_pair(make_pair(i,j),make_pair(i+1,j)));
				}
			}
		}
	printf("%d\n",ans.size());
	for(auto i : ans)
	{
		printf("%d %d %d %d\n",i.first.first,i.first.second,i.second.first,i.second.second);
	}
}

Measured memory_bytes: 5104