akhauriyash/Code-Regression huggingface dataset:
# ABC127D - Integer Cards
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
num = sorted(list(map(int, input().rstrip().split())))
lst = sorted([list(map(int, input().rstrip().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)
ans = 0
idx = 0
flg = False
for i, j in lst:
    for _ in range(i):
        if idx < n and num[idx] < j:
            ans += j
            idx += 1
        else:
            flg = True
            break
    if flg:
        break
if idx < n:
    ans += sum(num[idx:])
print(ans)

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


int main() {
    Int N, K;
    cin >> N >> K;

    Int ans = 0;
    ans += (N/K) * (N/K) * (N/K);

    if (K % 2 == 0) {
        Int k, x;
        k = K / 2;
        x = (N / k) - (N / K);
        ans += x * x * x;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    for(int i=n-2;i>=0;i--){
        if(h[i]<=h[i+1]) continue;
        else if(h[i]-1==h[i+1]) h[i]--;
        else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3984
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    }

    // let ans = if a + b >= k {
    //     a
    // } else {
    //     let d = k - (a + b);
    //     a - d
    // };
    let d = std::cmp::max(k - (a + b), 0);
    let ans = if a >= k { k } else { a - d };
    println!("{}", ans);
}


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

ll gcd(ll a, ll b) {
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

ll lcm(ll a, ll b){
   return a*b/gcd(a, b);
}


int main(){
	ll N, M;
	cin >> N >> M;	
	string S, T;
	cin >> S >> T;

	ll L = lcm(N, M);
	ll G = gcd(N, M);
	ll n = N/G;
	ll m = M/G;
	rep(i,G) {
		if (S[i*n] != T[i*m]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << L << endl;
	return 0;
}


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

using namespace std;

int main() {
  string str;
  getline(cin, str);
  cout << str.at(0);
  for (int i = 1; i < str.size(); i++) {
    if (str.at(i - 1) == ' ') {
      cout << str.at(i);
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,k;cin>>a>>b>>k;
  if(b-a+1<=2*k){
    for(int i=a;i<=b;i++){
      P(i);
    }
  }else{
    for(int i=a;i<=a+k-1;i++){
      P(i);
    }
    for(int i=b-k+1;i<=b;i++){
      P(i);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
ll n,m,c;
cin >>n>>m>>c;
ll b[m];ll a[n][m];
for(ll i=0;i<m;i++) cin >>b[i];
for(ll i=0;i<n;i++){
  for(ll j=0;j<m;j++){
    cin >> a[i][j];
  }
}
 ll ans=0;
for(ll i=0;i<n;i++){
  ll k=0;
  for(ll j=0;j<m;j++){
    k+=(a[i][j]*b[j]);
  }
  if(k+c>0) ans++;
}
 cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct RGC{int l,nxt,lmt;}rgc[309];
int h[309],n,m,tot=0,sum[309][309][309],mod=1000000007,ans=0;
void add(int x,int y,int z){
	rgc[++tot].l = x;
	rgc[tot].lmt = z;
	rgc[tot].nxt = h[y];
	h[y] = tot;
}
bool check(int x,int y,int z){
	int nn = max(x, max(y, z));
	int t = h[nn];
	while(t){
		int judge = (x >= rgc[t].l) + (y >= rgc[t].l) + (z >= rgc[t].l);
		if(judge != rgc[t].lmt)	return 0;
		t = rgc[t].nxt;
	}
	return 1;
}
int _plus(int x,int y){
	return x + y >= mod ? (x + y) % mod : (x + y);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= m; i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		add(l,r,x);
	}
	sum[1][0][0]=sum[0][1][0]=sum[0][0][1]=1; 
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n; j++)
			for(int k = 0; k <= n; k++){
				if(!sum[i][j][k])	continue;
				if(!check(i,j,k))	{sum[i][j][k] = 0;continue;}
				int nmax=max(i,max(j,k));
				sum[nmax + 1][j][k] = _plus(sum[i][j][k],sum[nmax + 1][j][k]);
				sum[i][nmax + 1][k] = _plus(sum[i][j][k],sum[i][nmax + 1][k]);
				sum[i][j][nmax + 1] = _plus(sum[i][j][k],sum[i][j][nmax + 1]);
			}
	for(int j = 0; j <= n; j++)
		for(int k = 0; k <= n; k++){
			ans = _plus(ans,sum[n][j][k]);
			ans = _plus(ans,sum[j][n][k]);
			ans = _plus(ans,sum[j][k][n]);
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 112896
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N, W = map(int, input().split())
    weights = []
    values = []
    for i in range(N):
        w, v = map(int, input().split())
        weights.append(w)
        values.append(v)
    V = max(values)
    dp = [[float("inf")] * (N * V + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        w = weights[i]
        v = values[i]
        for j in range(N * V + 1):
            if j >= v:
                dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j])
            else:
                dp[i + 1][j] = dp[i][j]
    for j in range(N * V):
        if dp[-1][-j - 1] <= W:
            print(N * V - j)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 302824
#include <bits/stdc++.h>
typedef long long int ll;
#define For(x,y) for(int x=0; x<y; x++)
using namespace std; 
int main()
{
    ll i,n;
    cin>>n;
    map<string,int> m;
    For(i,n)
    {
        string s;
        cin>>s;
        if(m.count(s)==0)
            m.insert(pair<string,int>(s,1));
    }
    cout<<m.size();
    return 0;
}

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

namespace ConsoleApplication1
{
    struct Point { internal double x, y; }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] arr = Array.ConvertAll(input.Split(','), double.Parse);

                Point a, b, c, d;
                a.x = arr[0]; a.y = arr[1];
                b.x = arr[2]; b.y = arr[3];
                c.x = arr[4]; c.y = arr[5];
                d.x = arr[6]; d.y = arr[7];

                if (GetPos(a, c, b) * GetPos(a, c, d) < 0 && GetPos(b, d, a) * GetPos(b, d, c) < 0)
                {
                    sb.AppendLine("YES");
                }
                else sb.AppendLine("NO");
            }
            Console.Write(sb);
        }

        static double GetPos(Point p0, Point p1, Point p2)
        {
            Point a = Sub(p1, p0);
            Point b = Sub(p2, p0);
            return a.x * b.y - a.y * b.x;
        }

        static Point Sub(Point a, Point b)
        {
            Point ret;
            ret.x = a.x - b.x;
            ret.y = a.y - b.y;
            return ret;
        }
    }
}

Measured memory_bytes: 9172
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<vector>
    using namespace std;
    int main()
    {
        string s;
        int p=0,m=0;
        cin>>s;
        for(int i=0;i<4;i++){
            if(s[i]=='+')
            p++;
            if(s[i]=='-')
            m--;
        }
        cout<<p+m<<endl;
    }

Measured memory_bytes: 764
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
char now_ans[1500][1500], ans[1500][1500];
ll stx, sty;

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

  cin >> h >> w >> d;
  rep(i, 1200) {
    rep(j, 1200) {
      stx = d * j, sty = d * i;
      if (stx > 1100 || sty > 1100) continue;
      rrep(zx, stx, stx + d) {
        if (zx > 1100) break;
        rrep(zy, sty, sty + d) {
          if (zy > 1100) break;
          if (i % 2 == 0) {
            // G or B
            if (j % 2 == 0)
              now_ans[zy][zx] = 'G';
            else
              now_ans[zy][zx] = 'B';
          } else {
            if (j % 2 == 0)
              now_ans[zy][zx] = 'Y';
            else
              now_ans[zy][zx] = 'R';
          }
        }
      }
    }
  }

  rep(i, 1100) {
    rep(j, 1100) {
      ll ansx, ansy;
      if ((i + j - (w - 1)) % 2 == 1) continue;
      ansy = (i + j - (w - 1)) / 2;
      ansx = i - ansy;
      if (ansx < 0 || ansx >= w || ansy < 0 || ansy >= h) continue;
      ans[ansy][ansx] = now_ans[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) { cout << ans[i][j]; }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = a - 2*b;

    if(ans<0){
        ans = 0;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll x;
  cin >> x;
  ll n = sqrt(2*x);
  if(n*(n+1)/2 < x) cout << n+1 << endl;
  else cout << n << endl;
  return 0;
}

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

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

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

    int all_price = 0;
    for (unsigned int i = 0; i < N + 1; ++i) {
        all_price += abs(A[i + 1] - A[i]);
    }

    for (unsigned int i = 1; i <= N; ++i) {
        int reduced_price_i = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]) - abs(A[i + 1] - A[i - 1]);
        int total_price_i = all_price - reduced_price_i;
        cout << total_price_i << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
n = int(input())
R = [None] * n
for i in range(n):
  R[i] = int(input())

def main():
  max_profit = -10 ** 9
  min_value = R[0]

  for i in range(1, n):
    if (max_profit < R[i] - min_value):
      max_profit = R[i] - min_value
    if (R[i] < min_value):
      min_value = R[i]

  return(max_profit)

print(main())


Measured memory_bytes: 13372
def lcs_len(x, y):
    indices = [0]
    for y_i in y:
        t_index = 0
        for i, index in enumerate(indices, 1):
            c_index = x.find(y_i, t_index) + 1
            if c_index:
                if i < len(indices):
                    t_index = indices[i]
                    indices[i] = min(c_index, t_index)
                else:
                    indices.append(c_index)
                    break
    print(len(indices) - 1)


q = int(input())

for i in range(q):
    ax = input()
    ay = input()
    lcs_len(ax, ay)

Measured memory_bytes: 7752
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:i64 = read();
    let m:usize = read();
    let mut sum = 0;
    for _ in 0..m {
        sum += read::<i64>();
    }
    println!("{}", std::cmp::max(-1, n-sum));
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
const long long INF = 1LL<<60;

int R, C, N, M;
Graph G;

vector<int> tmp;
vector<long long> vals;

bool rec(int v, long long val) {
    vals[v] = val;
    for (auto e : G[v]) {
        if (vals[e.first] != -1) {
            if (val + vals[e.first] != e.second) return false;
            continue;
        }
        if (!rec(e.first, e.second - val)) return false;
    }
    tmp.push_back(v);
    return true;
}   

int main () {
    cin >> R >> C >> M;
    int N = R+C;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < M; ++i) {
        int r, c;
        long long a;
        cin >> r >> c >> a;
        --r, --c;
        c += R;
        G[r].push_back({c, a});
        G[c].push_back({r, a});
    }

    bool res = true;
    vals.assign(N, -1);
    for (int v = 0; v < N; ++v) {
        if (vals[v] != -1) continue;
        tmp.clear();
        if (!rec(v, 0)) res = false;
        long long lmi = INF, rmi = INF;
        for (auto t : tmp) {
            if (t < R) lmi = min(lmi, vals[t]);
            else rmi = min(rmi, vals[t]);
        }
        if (lmi + rmi < 0) res = false;
    }
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 17020
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,m;
    cin>>n;
    cout<<(1ll^n);
    return 0;
}


Measured memory_bytes: 3564
a,b = gets.chomp.split(' ').map{|n| n.to_i}
def check(i)
  case i
  when 1, 3, 5, 7, 8, 10, 12
    "a"
  when 4, 6, 9, 11
    "b"
  when 2
    "c"
  end
end

puts check(a) == check(b) ? "Yes" : "No"

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

using namespace std;

typedef long long ll;

int main(){
  char S[2222222];
  cin >> S;
  ll i = 0;
  while(S[i]){
    if(S[i]=='?') S[i] = 'D';
    i++;
  }
  cout << S << endl;
}

Measured memory_bytes: 3784
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};
const int D=365;
const int beam = 220;
int c[26];
int s[D][26];
int ans[D];

struct State{
    ll val = 0;
    int out[D]={0};
    int cnt[26]={0};
};

bool operator< (const State &a, const State &b){
    return a.val<b.val;
}
bool operator> (const State &a, const State &b){
    return a.val>b.val;
}


void solve(int ca){
    int waste;
    scanf("%d",&waste);
    for (int i = 0; i < 26; ++i) {
        scanf("%d",c+i);
    }
    for (auto & i : s) {
        for (int & j : i) {
            scanf("%d",&j);
        }
    }

    priority_queue<State> pq[2];
    pq[0].push(State());
    for (int i = 0; i < D; ++i) {
        int prev=i&1,next = prev^1;
        for (int j = 0; !pq[prev].empty()&&j < beam; ++j) {
            auto state = pq[prev].top();
            pq[prev].pop();
            ll dec=0;
            for (int k = 0; k < 26; ++k) { 
                state.cnt[k]++;
                dec+=(ll)c[k]*state.cnt[k];
            }
            for (int k = 0; k < 26; ++k) {
                const ll inc = (ll)c[k]*state.cnt[k];
                const int tmp = state.cnt[k];
                const int tmp_val = state.val;
                state.val = state.val-dec+inc+s[i][k];
                state.cnt[k]=0;
                state.out[i]=k;
                pq[next].push(state);
                state.cnt[k]=tmp;
                state.val = tmp_val;
            }
        }
        pq[prev]=priority_queue<State>();
    }
    auto best = pq[D&1].top().out;
    for (int i = 0; i < D; ++i) {
        ans[i]=best[i]+1;
    }
    for (int i = 0; i < D; ++i) {
        printf("%d\n",ans[i]);
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 33592
#include<bits/stdc++.h>
int a[100002]={1000000001,1000000001},b[50000];
using namespace std;
int main()
{
	int n,h=0,ma=0;
	cin>>n;
	for(int t=2;t<=n+1;t++)
	{
		cin>>a[t];
	}
	for(int t=2;t<=n+1;t++)
	{
		if(a[t]<=a[t-1])
		{
			b[h]++;
			//cout<<"b["<<h<<"]="<<b[h]<<"(a["<<t<<"]) ";
		}
		else
		{
			if(a[t-1]<=a[t-2])
			{
				//cout<<a[t-2]<<" "<<a[t-1]<<" "<<a[t]<<endl;
				h++;
			}
			continue;
		}
	}
	b[0]=b[0]-1;
	for(int t=0;t<=h;t++)
	{
		//cout<<ma<<" "<<b[t]<<" ";
		if(b[t]>ma)
		{
			ma=b[t];
		}
	}
	cout<<ma;
	return 0;
} 

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

int main(){
  int r, c;
  cin >> r >> c;
  vector<vector<int> > tab(r + 1, vector<int>(c + 1, 0));
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> tab.at(i).at(j);
    }
  }

  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      tab.at(i).at(c) += tab.at(i).at(j);
    }
  }

  for(int i = 0; i < c; i++){
    for(int j = 0; j < r; j++){
      tab.at(r).at(i) += tab.at(j).at(i);
    }
  }

  for(int i = 0; i < r; i++){
      tab.at(r).at(c) += tab.at(i).at(c);
  }

  for(int i = 0; i < r + 1; i++){
    for(int j = 0; j < c + 1; j++){
      cout << tab.at(i).at(j);
      if(j == c){
        cout << endl;
      }
      else{
        cout << " " ;
      }
    }
  }
}


Measured memory_bytes: 3212
roop = gets.to_i
for i in 0 ...roop do
	data = gets
	hai = data.split
	hai.collect! {|i|i.to_i}
	hai.sort!
	if hai[0]**2 + hai[1]**2 == hai[2]**2 then
		print "YES\n"
	else
		print "NO\n"
	end
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,x[100010];
L l,r;
inline bool orz(L &l,L &r,int x)
{
    if(r/x*x<l)
      return 1;
    r=r/x*x+x-1;
    l=(l-1)/x*x+x;
    return 0;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d",&x[i]);
	l=r=2;
	for(i=n;i>0;i--)
      if(orz(l,r,x[i]))
        {
         printf("-1\n");
         return 0;
        }
    cout<<l<<" "<<r<<"\n";
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N;
	long long K, A[100001];
	scanf("%d %lld", &N, &K);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long g = A[1], max = A[1];
	for (i = 2; i <= N; i++) {
		g = gcd(g, A[i]);
		if (A[i] > max) max = A[i];
	}
	if (K <= max && K / g * g == K) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
    using namespace std;
     
    inline void upmax(short &x,const short &y){if(y>x) x=y;}
     
    const int N=105;
    short f[N][N][N][N];
    short sum1[N][N],sum2[N][N];
    int n,m,tx,ty;
     
    void gao()
    {
        int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
        for(int u=0;u<=limu;u++)
            for(int d=0;d<=limd;d++)
                for(int l=0;l<=liml;l++)
                    for(int r=0;r<=limr;r++)
                    {
                        int L=max(ty-l,r+1),R=min(ty+r,m-l);
                        if(L<=R)
                        {
                            upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
                            upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
                        }
                        L=max(tx-u,d+1),R=min(tx+d,n-u);
                        if(L<=R)
                        {
                            upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
                            upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
                        }
                    }
        printf("%d\n",f[limu][limd][liml][limr]);
    }
     
    int main()
    {
        static char s[105];
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)
        {
            scanf("%s",s+1);
            for(int j=1;j<=m;j++)
            {
                if(s[j]=='E') tx=i,ty=j;
                sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
                sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
            }
        }
        gao();
        return 0;
    }

Measured memory_bytes: 67712
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int N = sc.nextInt();
		int total = 0;
		for(int i=0; i<N; i++)
			total += sc.nextInt();
		
		System.out.println(total>=H ? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 48556
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
graph = [[] for _ in range(N)]

for a, b in AB:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# 二部グラフかどうかの判定
color = [None] * N
color[0] = 0
q = [0]
while q:
    x = q.pop()
    for y in graph[x]:
        if color[y] is None:
            color[y] = 1 - color[x]
            q.append(y)

# 二部グラフかどうか
is_bg = all(color[a-1] != color[b-1] for a, b in AB)

if is_bg:
    # 完全二部グラフにする
    x = sum(color)
    y = N - x
    answer = x*y - M
else:
    # 完全グラフにする(奇数長のパスがある場合は必ず2ずつ減らしていけば長さが3になる)
    answer = N*(N-1)//2 - M

print(answer)

Measured memory_bytes: 42128
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;




int main() {

	int n,C;
	cin >> n>>C;
	auto d = mat(int, C, C, 0);
	rep(i, 0, C) {
		rep(j, 0, C) {
			cin >> d[i][j];
		}
	}
	auto c = mat(int, n, n, 0);
	rep(i, 0, n) {
		rep(j, 0, n)cin >> c[i][j];
	}

	auto cost = mat(int, 3, C, 0);
	rep(i, 0, 3) {
		rep(j, 0, C) {
			rep(k, 0, n)rep(l, 0, n) {
				if((k+l)%3==i) cost[i][j] += d[c[k][l]-1][j];
			}

		}
	}
	int mi = INT32_MAX;
	rep(g1, 0, C) {
		rep(g2, 0, C) {
			rep(g3, 0, C) {
				if (g1 == g2 || g2 == g3 || g3 == g1)continue;
				mi = min(mi, cost[0][g1] + cost[1][g2] + cost[2][g3]);
			}
		}
	}
	cout << mi;


	return 0;
}





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

using namespace std;

template<class T>
struct BIT_2D {
	int R, C;
	vector<vector<T>> bit;
	BIT_2D(int r, int c) {
		R = r;
		C = c;
		bit.resize(r+1, vector<T>(c+1, 0));
	}
	void add(int r, int c, T v) {
		for (int i = r+1; i <= R; i += i & -i) {
			for (int j = c+1; j <= C; j += j & -j) {
				bit[i][j] += v;
			}
		}
	}
	T get(int r, int c) {
		T res = 0;
		for (int i = r+1; i; i -= i & -i) {
			for (int j = c+1; j; j -= j & -j) {
				res += bit[i][j];
			}
		}
		return res;
	}
	T get_sum(int r1, int c1, int r2, int c2) {
		r1--; c1--; r2--; c2--;
		return get(r2, c2) - get(r1, c2) - get(r2, c1) + get(r1, c1);
	}
};

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	BIT_2D<long long> bit(N, N);
	while (M--) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		bit.add(l, r, 1);
	}
	while (Q--) {
		int l, r;
		cin >> l >> r;
		l--;
		cout << bit.get_sum(l, l, r, r) << endl;
	}
}



Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  int cnt=0;
  cin >> n >> m;
  
  vector<int> v,x;
 
  int a,b;
  for(int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  x = v;
  
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    if(v[a] < v[b]) {
      x[a] = -1;
    }
    else if(v[a] == v[b]) {
      x[a] = -1;
      x[b] = -1;
    }else if(v[b] < v[a]) {
      x[b] = -1;
    }
  }
 
  cout << v.size() - count(x.begin(), x.end(), -1) << "\n";
  return 0;
}

Measured memory_bytes: 4188
#include<iostream>

using namespace std;

#define NMAX 100
#define MMAX 100

int main(){

	int n,m;
	int ns[NMAX],ms[NMAX];
	int nsum,msum;
	int ansn,ansm;

	while(1){

		cin>>n>>m;
		if(n==0&&m==0) break;

		nsum=0,msum=0;
		for(int i=0;i<n;i++){
			cin>>ns[i];
			nsum+=ns[i];
		}
		for(int i=0;i<m;i++){
			cin>>ms[i];
			msum+=ms[i];
		}
		
		ansn=-1,ansm=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(nsum-ns[i]+ms[j]==msum-ms[j]+ns[i]){
					if(ansn==-1&&ansm==-1||ns[i]+ms[j]<ansn+ansm){
						ansn=ns[i];
						ansm=ms[j];
					}
				}
			}
		}
		if(ansn==-1&&ansm==-1) cout<<"-1"<<endl;
		else cout<<ansn<<" "<<ansm<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int n,k,ok,r;
string s;
int main (void) {
    cin >> n;
    while (n != 0) {
        r = n % (-2);
        n = n / -2;

        if (r < 0) {
            r += 2;
            n ++;
        }
        s = to_string (r) + s;
    }
    if (s.empty() == 1) {
        cout << 0;
    }
    else {
        cout << s;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)


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

int main(void){
  string s; cin >> s;
  deque<char> q;
  rep(i,s.size()){
    q.push_back(s.at(i));
  }
  int x; cin >> x;
  int rv = 0;
  rep(i,x){
    int t; cin >> t;
    if(t == 1){
      rv++;
    }
    else{
      int f; cin >> f;
      char c; cin >> c;
      if(f == 1){
        if(rv % 2 == 0){
          q.push_front(c);
        }
        else{
          q.push_back(c);
        }
      }
      else{
        if(rv % 2 == 0) q.push_back(c);
        else q.push_front(c);
      }
    }
  }
  if(rv % 2 == 0){
    rep(i,q.size()){
      cout << q[i];
    }
    cout << endl;
  }
  else{
    rep(i,q.size()){
      cout << q[q.size() - i -1];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>          
using namespace std;
typedef long long ll;
typedef long double ld;
/*
void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
*/
int main() {
    int N;
    cin >> N;
    vector<ld> x(N), y(N);
    for (int i=0; i<N; i++) cin >> x[i] >> y[i];
    vector<ld> base(N), L(N-1);
    for (int i=0; i<N; i++) base[i] = i;
    int p=1;
    for (int i=1; i<=N; i++) p*=i;
    ld cnt = 0;
    for (int i=0; i<p; i++) {
        for (int j=0; j<N-1; j++) {
            cnt += sqrt(pow(x[base[j+1]]-x[base[j]],2)+pow(y[base[j+1]]-y[base[j]],2));
        }
        next_permutation(base.begin(),base.end());
    }
    ld ans = cnt/p;
    cout << fixed << setprecision(8);
    cout << ans << endl;
}

Measured memory_bytes: 3824
#include<iostream>

#define DIV 1000000007

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int S[N+1], T[M+1];
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    S[N] = -1;
    for(int i=0; i<M; i++){
        cin >> T[i];
    }
    T[M] = -1;

    long dp[N+1][M+1];
    long sum[N+1][M+1];
    for(int i=0; i<N+1; i++){
        fill(dp[i], dp[i] + M + 1, 0);
    }
    for(int i=0; i<N+1; i++){
        fill(sum[i], sum[i] + M + 1, 0);
    }

    for(int i=0; i<N+1; i++){
        for(int j=0; j<M+1; j++){
            if(i == 0 || j == 0){
                dp[i][j] = long(S[i] == T[j]);
                sum[i][j] = 0;
            }
            else{
                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i-1][j-1] + DIV;
                sum[i][j] %= DIV;
                if(S[i] == T[j]){
                    dp[i][j] = sum[i][j] + 1;
                    dp[i][j] %= DIV;
                }
            }
        }
    }

    cout << dp[N][M] << endl;
    return 0;
}

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

    int i, a, b;
    int count;
    
    scanf("%d", &a); scanf("%d", &b);

    if(a <= b){
        count = a;
    }else{
        count = a - 1;
    }

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

    return 0;
}


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

const int MAXN = 50005;
bool isP[MAXN];

int main() {
  fill(isP, isP+MAXN, true);
  isP[0] = isP[1] = false;
  for(int i = 0; i < MAXN; ++i) {
    if(!isP[i]) continue;
    for(int j = i*2; j < MAXN; j += i) isP[j] = false;
  }
  int n;
  while(cin >> n && n) {
    int res = 0;
    for(int i = 2; i <= n-i; ++i) {
      if(isP[i] && isP[n-i]) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e4 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	use_fast;
    int n;
    cin >> n;
    n *= 2;
    for(int i = 0; i < n; i++) 
		cin >> a[i];
    int ans = 0;
    sort(a, a + n);
    reverse(a, a + n);
    for(int i = 1; i < n; i += 2) 
        ans += a[i];
    cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var D = int.Parse(Console.ReadLine());
            var C = RL<long>();
            var Co = Enumerable.Repeat(0, 26).ToArray();
            var S = new List<long>[D];
            for (var i = 0; i < D; i++) S[i] = RL<long>().ToList();
            long ans = 0;
            for (var i = 0; i < D; i++) {
                var tmp = new int[26];
                Array.Copy(Co, tmp, Co.Length);
                long tmpans = 0;
                var T = 0;
                for (var t = 0; t < 26; t++) {
                    Array.Copy(tmp, Co, tmp.Length);
                    long m = 0;
                    for (var a = 0; a < 26; a++) {
                        if (t == a) {
                            Co[a] = 0;
                            continue;
                        }
                        Co[a]++;
                    }
                    for (var a = 0; a < 26; a++) {
                        m += Co[a] * C[a];
                    }
                    if(S[i][t] - m > tmpans) {
                        T = t;
                        tmpans = S[i][t] - m;
                    }
                    //Console.WriteLine("{0}day {1}=t {2}", i + 1, t + 1, S[i][t] - m);
                }
                Co = tmp;
                for (var a = 0; a < 26; a++) {
                    if (T == a) {
                        Co[a] = 0;
                        continue;
                    }
                    Co[a]++;
                }
                Console.WriteLine(T + 1);
            }
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}

Measured memory_bytes: 29132
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <string.h>
using namespace std;


int main()
{

string N;
int count=0;
int max=0;
getline(cin,N);

for(int i=0;i<10;i++){
if(N[i]=='A'){
  count=count+1;
  if(count>max)max=count;
}else if(N[i]=='T'){
  count=count+1;
  if(count>max)max=count;
}else if(N[i]=='C'){
  count=count+1;
  if(count>max)max=count;
}else if(N[i]=='G'){
  count=count+1;
  if(count>max)max=count;
}else count=0;
//cout<<max<<endl;
}

cout<<max<<endl;
return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <ii, int> iii;

const int siz = 2e5 + 10;
const int SIZ = 2e3 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e12;
const string file = "2";

int ans;

struct point {
    int x, y;

    point(int x, int y) : x(x), y(y) {
    }

    point() {
    }

    bool operator < (const point &p) const {
        if (x != p.x) {
            return x < p.x;
        }
        return y < p.y;
    }
};

bool cw(point a, point b, point c) {
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) < 0);
}

bool ccw(point a, point b, point c) {
    return (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) > 0);
}

vector <point> convex_hull(vector <point> pts) {
    set <point> tmp;
    for (auto &pt : pts) {
        tmp.insert(pt);
    }

    pts.clear();
    for (auto &pt : tmp) {
        pts.push_back(pt);
    }

    if (sz(pts) == 1) {
        return pts;
    }

    point pt1 = pts.front(), pt2 = pts.back();
    vector <point> up = {pt1}, down = {pt1};
    for (int i = 1; i < sz(pts); i++) {
        if (i == sz(pts) - 1 || cw(pt1, pts[i], pt2)) {
            while (sz(up) >= 2 && !cw(up[sz(up) - 2], up.back(), pts[i])) {
                up.pop_back();
            }
            up.push_back(pts[i]);
        }

        if (i == sz(pts) - 1 || ccw(pt1, pts[i], pt2)) {
            while (sz(down) >= 2 && !ccw(down[sz(down) - 2], down.back(), pts[i])) {
                down.pop_back();
            }
            down.push_back(pts[i]);
        }
    }

    auto dist = [](point a, point b) -> int {
        return (abs(a.x - b.x) + abs(a.y - b.y));
    };

    for (auto &pt1 : up) {
        for (auto &pt2 : down) {
            ans = max(ans, dist(pt1, pt2));
        }
    }

    vector <point> res;
    for (auto &pt : up) {
        res.push_back(pt);
    }
    down.pop_back();
    reverse(all(down));
    down.pop_back();
    for (auto &pt : down) {
        res.push_back(pt);
    }

    return res;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n;
    cin >> n;

    vector <point> pts(n);
    for (auto &pt : pts) {
        cin >> pt.x >> pt.y;
    }

    vector <point> ch = convex_hull(pts);

    cout << ans << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 21956
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>

using namespace std;

int main() {
	int N;
	string S;
	int K;
	cin >> N >> S >> K;
	
	K--;
	
	char same = S.at(K);
	
	for (int i = 0; i < N; i++) {
		if (S.at(i) == same) {
		} else {
			S.at(i) = '*';
		}
	}
	
	cout << S << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,a,b,c,d,x,y;
  cin>>n;
  d = n%10;
  n = n/10;
  c = n%10;
  n = n/10;
  b = n%10;
  n = n/10;
  a = n%10;
  x = a*10+b;
  y = c*10+d;
  if(x>12 || x<1)
  {
    if(y>12 || y<1)
    {
      cout<<"NA";
    }
    else
      cout<<"YYMM";
  }
  else
  {
    if(y>12 || y<1)
    {
      cout<<"MMYY";
    }
    else
      cout<<"AMBIGUOUS";
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    ll x;
    cin >> x;
    ll money=100, cnt=0;
    while(true){
        money += money / 100;
        cnt++;
        if(money >= x){
            out(cnt);
            return 0;
        }
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int x;
	int ans=0;
	
	cin>>x;
	if(x<1200)
		cout<<"ABC"<<endl;
	else
		cout<<"ARC"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

#define DEBUG
#ifdef DEBUG
// #include "debug.h"
#else
#define debug(...) 42
#endif

const int M = 8e3+1;
const int MD=998244353;

int a[M];
ll dp[M][M],ans=0,pre[M][M];
int main() {
	fast_cin();
    int n,s;
	cin>>n>>s;	
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=s;j++){
			if(j==0){
				dp[i][j+a[i]]=i;
			}
			else{
				dp[i][j+a[i]]=(dp[i][j+a[i]]+pre[i-1][j])%MD;
			}
		}
		for(int j=0;j<=s;j++){
			pre[i][j]=(pre[i-1][j]+dp[i][j])%MD;
		}
	}
	for(int i=1;i<=n;i++){
		ans=(ans+((n-i+1)*dp[i][s])%MD)%MD;
	}
	cout<<ans;
	return 0;
}

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


int main()
{
    stringstream ss;
    // 入力
    int N;
    cin>>N;

    bool prime[55556];
    for(int i=2;i<55556;i++){
    	prime[i]=true;
    	for(int j=2;j*j<=i;j++){
    		if(i%j==0) {
    			prime[i]=false;
    			break;
    		}
    	}
    }
    int ansnum=0;
    int a=11;
	while(ansnum<N){
		if(a>55555) {
			cout<<"prime not found"<<endl;
			return 0;
		}
		if(a%5==1 && prime[a]){
			if(ansnum==N-1) cout<<a<<endl;
			else cout<<a<<" ";
			ansnum++;
		}
		a+=10;
	}
    return 0;
}

Measured memory_bytes: 256
n,k = gets.chomp.split(' ').map(&:to_i)
while true
  if n <= 0
    can = n.abs
    break
  end
  if n / k > 2 #kに対してnが大きい場合はショートカットする
    n -= ((n / k) - 2) * k #kに大きめの値を掛けたものを引く
  else
    n -= k #nがkの2倍未満なら普通にkを引く
  end
end
if can < n + k
  puts can
else
  puts n + k
end

Measured memory_bytes: 14288
function Main(input) {
  var args = input.split(' ');
  var a = parseInt(args.shift());
  var b = parseInt(args.shift());
  var c = parseInt(args.shift());
  console.log((a <= c && c <= b) || (b <= c && c <= a) ? 'Yes' : 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastReader
        {
            BufferedReader br;
            StringTokenizer st;

            public FastReader()
            {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

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

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

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

            double nextDouble()
            {
                return Double.parseDouble(next());
            }

            String nextLine()
            {
                String str = "";
                try
                {
                    str = br.readLine();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
                return str;
            }
        }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        int k=ob.nextInt(),a=ob.nextInt(),b=ob.nextInt();
        int ans=(a-(a%k))+k;
        if(ans>=a && ans<=b || a%k==0){
            System.out.println("OK");
            return;
        }
        System.out.println("NG");
    }
}


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

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

  vector<int64_t> A(100010, 0);
  A.at(0) = 1;
  bool is_zero = false;
  for (int n = 1; n <= N; n++){
    cin >> A.at(n);
    if (A.at(n) == 0){
      is_zero = true;
    }
  }

  if (is_zero){
    cout << "0" << endl;

  }else{
  
    int64_t a = 1;
    int64_t b, m;
  
    for (int n = 1; n <= N; n++){
      b = A.at(n);
    
      m = a * b;
      if ((m > 1000000000000000000) || (m < a) || (m < b)){
	a = -1;
	break;
      }
      a = m;
    }
    cout << a << endl;
  }
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Line{
  Point s,t;
  Line(){}
  Line(Point s,Point t) : s(s),t(t) {}
};

Point projection(Line l,Point p){
  Vector b = l.t-l.s;
  double t = dot(p-l.s,b)/norm(b);
  return l.s+b*t;
}

int main(){
  Line l;
  int Q;
  Point p;
  cin >> l.s >> l.t >> Q;
  while(Q--){
    cin >> p;
    Point p2 = projection(l,p);
    printf("%.10f %.10f\n",p2.x,p2.y);
  }
  return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}

	static long g(int R , int C){
		long fact[] = new long[R + C + 3];
		fact[0] = 1;
		fact[1] = 1;
		for(int i = 2 ; i < fact.length ; ++i){
			fact[i] = ((long)(i) * fact[i - 1]) % MOD;
		}
		long pat = fact[R + C + 2] ;
		pat = (pat * modinv(fact[R + 1])) % MOD;
		pat = (pat * modinv(fact[C + 1])) % MOD;
		return pat;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r1 = sc.nextInt();
		int c1 = sc.nextInt();
		int r2 = sc.nextInt();
		int c2 = sc.nextInt();
		long ret = g(r2 , c2) + g(r1 - 1 , c1 - 1) + 2 * MOD - (g(r1 - 1 , c2) + g(r2, c1 - 1));
		System.out.println(ret % MOD);
	}
}


Measured memory_bytes: 82512