akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
 
using namespace std;
//ofstream fout("test.in");
 
const int maxn = 30000;
int p[10] = {2 , 3 , 5};
bool mark[maxn];
int cnt = 0 , mod , N;
vector <int> v[30];
int sum[30];
void solve(){
	if(N <= 12){
		if(N == 3)
			cout << "2 5 63" << endl;
		else{
			cout << 2 << " " << 3 << " " << 4 << " " << 9;
			if(N >= 5)
				cout << " " << 12;
			if(N >= 6)
				cout << " " << 24;
			if(N >= 7)
				cout << " " << 48;
			if(N >= 8)
				cout << " " << 96;
			if(N >= 9)
				cout << " " << 192;
			if(N >= 10)
				cout << " " << 384;
			if(N >= 11)
				cout << " " << 768;
			if(N == 12)
				cout << " " << 1536; 
			cout << endl;
		}
	}
	else{
		mark[2] = mark[3] = 1;
		int cnt = 2 , cur = 5;
		mod = 6;
		for(int i = 4 ; i <= maxn ; i += 2)
			if(!mark[i]){
				cnt ++;
				mark[i] = 1;
				v[i % mod].push_back(i);
				sum[i % mod] ++;
				cur = (cur + i) % mod;
			}
		for(int i = 6 ; i <= maxn ; i += 3)
			if(!mark[i]){
				cnt ++;
				mark[i] = 1;
				v[i % mod].push_back(i);
				sum[i % mod] ++;
				cur = (cur + i) % mod;
			}
		if(N == 20000){
			cout << 2 << " " << 3 << " ";
			for(int i = 0 ; i < mod ; ++ i)
				for(int j = 0 ; j < sum[i] ; ++ j)
					cout << v[i][j] << " ";
			cout << endl;
			return ;
		}
		while(N != cnt - 1){
			for(int i = 0 ; i < mod ; ++ i)
				if(sum[i] && sum[i] != 1){
					sum[i] --;
					cur = (cur + mod - i) % mod;
					break;
				}
			cnt --;
		}
		if(cur == 1){
			sum[2] ++;
			sum[3] --;
			sum[0] --;
		}
		else
			sum[cur] --;
		cout << 2 << " " << 3 << " ";
		for(int i = 0 ; i < mod ; ++ i)
			for(int j = 0 ; j < sum[i] ; ++ j)
				cout << v[i][j] << " ";
		cout << endl;
	}
}
int main(){
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    const int MAX_V_SUM = 200000;
    int N, W;
    cin >> N >> W;

    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N + 1, vll(MAX_V_SUM + 1, INF));
    dp[0][0] = 0;

    rep(i, N)
    {
        reple(j, 0, MAX_V_SUM)
        {
            chmin(dp[i + 1][j], dp[i][j]);
            if(j - v[i] >= 0) chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }

    revrep(i, MAX_V_SUM + 1)
    {
        if (dp[N][i] <= W)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a[100005];long long n,i,j,k,l,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		for(j=0;j<9;j++){
			for(k=j+1;k<10;k++)if(a[i][j]>a[i][k])swap(a[i][j],a[i][k]);
		}
	}
	sort(a+1,a+n+1);
	string last;
	for(int i=1;i<=n;i++){
		last=a[i];l=i;
		while(a[i+1]==last&&i<n)i++;
		ans+=((i-l)*(i-l+1)>>1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

//Room Numbers of a Hospital
public class Main {

	static int[] t = {0,1,2,3,5,7,8,9};
	
	static void f(int n){
		if(n>=8)f(n/8);
		System.out.print(t[n%8]);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			f(n);
			System.out.println();
		}
	}
}

Measured memory_bytes: 65272
import collections
def calc_prime(N):
  dic={}
  i=2
  while N != 1:
    d,m=divmod(N,i)
    if m==0:
      N=d
      if i not in dic:dic[i]=1
      else:dic[i]+=1
    else:
      i+=1
  return dic
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def main():
  N=int(input())
  #dic=calc_prime(N)
  dic=collections.Counter(prime_factorize(N))
  ans=0
  for k,v in dic.items():
    i=0
    while v > i:
      i+=1
      v-=i
    ans+=i
  print(ans)
if __name__ == '__main__':
  main()



Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

string makeString(char c, int l){
    string res;
    for (int i = 0; i < l; i++){
	res += c;
    }

    return res;
}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string res;
    int x = tx-sx;
    int y = ty-sy;
    res += makeString('U', y);
    res += makeString('R', x);
    res += makeString('D', y);
    res += makeString('L', x);

    res += 'L';
    res += makeString('U', y+1);
    res += makeString('R', x+1);
    res += "DR";
    res += makeString('D', y+1);
    res += makeString('L', x+1);
    res += 'U';

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n, k, q;
    cin >> n >> k >> q;
    int a[q];
    rep (i, q) cin >> a[i];

    vector<int> cnt(n + 1, 0);
    rep (i, q) cnt[a[i] - 1]++;

    rep (i, n) {
        if (k - (q - cnt[i]) >= 1)yn
    }

    return 0;
}

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

int main() {
  int N ; 
  cin >> N ;
  vector<pair<int,int>> P(N);
  rep(i,N) cin >> P[i].second >> P[i].first ;
  sort(P.begin(),P.end());
  int time = 0 ;
  for(int i = 0 ; i < N ; i++ ){
    time += P[i].second;
    if( time > P[i].first ) {
      cout << "No" ;
      return 0 ;
  }
  }
   cout << "Yes" ;
} 

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  ll sum = 0;
  int tmp;
  vector<int> a(n);
  REP(i, n){
    cin >> tmp;
    a[i] = tmp;
    sum += tmp;
  }
  long double threshold = (long double)sum / (4 * m); 

  sort(a.begin(), a.end(), greater<int>());

  int cnt = 0;
  string ans;
  for (int i: a){
    if (i >= threshold){
      cnt++;
    } else {
      ans = "No";
      break;
    }

    if (cnt >= m){
      ans = "Yes";
      break;
    } 
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N;

void input() {
    cin >> N;
}

void solve() {
    if (N == 3) {
        cout << 2 << endl;
        cout << 1 << ' ' << 3 << endl;
        cout << 2 << ' ' << 3 << endl;
        return;
    }
    
    vector<pair<ll, ll>> ans;
    auto n = N - (N%2);
    for (ll i = 1; i <= n; i++) {
        for (ll j = i + 1; j <= n; j++) {
            if (j == n - i + 1)
                continue;
            ans.push_back({i, j});
        }
    }
    if (N % 2) {
        for (ll i = 1; i <= n; i++)
            ans.push_back({i, N});
    }
    cout << ans.size() << endl;
    for (auto p : ans)
        cout << p.first << " " << p.second << endl;
    
}

int main() {
    input();
    //    cout << solve() << endl;
    solve();
    
    return 0;
}



Measured memory_bytes: 512
_ = gets.to_i
items = gets.chomp.split(' ').map(&:to_f).sort
while items.count > 1
  new_item = (items[0] + items[1]) / 2.0
  items.delete_at(0)
  items.delete_at(0)
  items.unshift(new_item)
end
puts items[0]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

const int max_v = 1000123, inf = 1e9 + 123;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, max_w;
	cin >> n >> max_w;
	vector<ll> dp(max_v, inf);
	dp[0] = 0;
	for(int i = 0; i < n; ++ i) {
		int w, v;
		cin >> w >> v;
		for(int j = max_v; j >= v; --j)
			dp[j] = min(dp[j], dp[j - v] + w);
	}
	ll answer = 0;
	for(int i = 0; i < max_v; ++ i) {
		
		if(dp[i] <= max_w) answer = i;
	}		
	cout << answer << '\n';
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, t;
  int c, time;
  int mini = INF;

  cin >> n >> t;
  for(int i = 0;i < n;i++){
    cin >> c >> time;
    if(time <= t && mini > c){
      mini = c;
    }
  }

  if(mini == INF){
    cout << "TLE" << endl;
  }else{
    cout << mini << endl;
  }
  return 0;
}



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

int main() {
	unsigned long long x, y;
	int ans = 0;
	cin >> x >> y;
	while(1) {
		if (x <= y) {
			ans++;
			//cout << x << endl;
		}
		else break;
		x *= 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll d;
  cin >> d;
  cout << "Christmas";
  for(ll i=0;i<25-d;i++)cout << " Eve";


}

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

int gen_rand(int r) {
  return ((r * r)%1000000)/100;
}

int main() {
  int n, r;
  cin >> n;
  for (int i=0; i<n; i++) {
    cout << "Case " << i+1 << ":" << endl;
    cin >> r;
    for (int j=0; j<10; j++) {
      r = gen_rand(r);
      cout << r << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
n = input()
keywords = list("MARCH")
m = len(keywords)
D = dict(zip(keywords, [0] * m))
for i in range(n):
    s = raw_input()
    c = s[0]
    if c in D:
        D[c] += 1
ans = 0
for i in range(m):
    for j in range(i+1, m):
        for k in range(j+1, m):
            ans += D[keywords[i]] * D[keywords[j]] * D[keywords[k]]
print ans

Measured memory_bytes: 5764
import std.stdio,std.string,std.conv,std.math;

int main()
{
	int count = 0;
	double ans = 0;
	double x[25];
	double y[25];
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(",");
		x[count] = _s[0].to!double;
		y[count] = _s[1].to!double;
		count++;
	}

	x[count] = x[0];
	y[count] = y[0];

	foreach(i;0..count)
	{
		ans += x[i]*y[i+1] - x[i+1]*y[i];
	}

	writeln(abs(ans)/2);
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int mn = numeric_limits<int>::max();

  // a, b, c
  mn = min(mn, abs(a - b) + abs(b - c));

  // a, c, b
  mn = min(mn, abs(a - c) + abs(c - b));

  // b, a, c
  mn = min(mn, abs(b - a) + abs(a - c));

  // b, c, a
  mn = min(mn, abs(b - c) + abs(c - a));

  // c, a, b
  mn = min(mn, abs(c - a) + abs(a - b));

  // c, b, a
  mn = min(mn, abs(c - b) + abs(b - a));

  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  ll num_size = 1e5 + 10;
  vector<ll> num(num_size, 0);
  for (ll i = 0; i < N; ++i) {
    ll A;
    cin >> A;
    num.at(A) += 1;
  }
  ll ans = 0;
  for (ll i = 0; i < num_size; ++i) {
    ans += num.at(i) * i;
  }
  ll Q;
  cin >> Q;
  for (ll i = 0; i < Q; ++i) {
    ll B, C;
    cin >> B >> C;
    ans -= B * num.at(B);
    ans += C * num.at(B);
    num.at(C) += num.at(B);
    num.at(B) = 0;
    cout << ans << "\n";
  }
}


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

int main(void) {
	string s;
	int w = 0;
	cin >> s >> w;
	for (int i = 0;i < s.length();i++) {
		if (i%w == 0)
			cout << s[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,i,j
    if (abs(n-i)> abs(n-j) )then
        write(*,*) 'B'
    else
        write(*,*) 'A'
    end if    
  
    stop
end program sample
  



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int d,n;
	d = sc.nextInt(); n = sc.nextInt();
	System.out.println((int)Math.pow(100 , d )* (n + (n / 100)));
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint MOD = 1000000007;

int N;
map<int, int> c;

int main()
{
    cin >> N;
    for (int i=0; i<N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == N % 2 || c[tmp] == 2)
        {
            cout << 0 << endl;
            return 0;
        }
        c[tmp]++;
    }
    if (c[0] > 1)
    {
        cout << 0 << endl;
        return 0;
    }
    lint ans = 1;
    for (int i=0; i<N/2; i++) ans = (ans * 2) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int v[N],freq[N];

int main(){

//	freopen("in.txt","r",stdin);

	int n;
	scanf("%d",&n);
	for(int i=1;i <= n;i++){
		scanf("%d",&v[i]);
	}
	int ans =0;
	for (int i=1; i<=n; i++){
		if (v[i] !=i)continue;
		ans++;
		if (i == n)break;
		swap (v[i], v[i+1]);
	}
	cout <<ans <<endl;
	return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

   map<string , int>m;

   while(n--){
      string s;
      cin >> s;
      m[s]++;
   }

   cout << "AC" << " x " << m["AC"] << "\n";
   cout << "WA" << " x " << m["WA"] << "\n";
   cout << "TLE" << " x " << m["TLE"] << "\n";
   cout << "RE" << " x " << m["RE"] << "\n";

}

Measured memory_bytes: 3628
# https://atcoder.jp/contests/abc054/tasks/abc054_c

import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

nmax=8
graph=[[False]*nmax for _ in range(nmax)]

def dfs(n,v,visited):
  all_visited=True
  for i in range(n):
    if visited[i]==False:
      all_visited=False
  if all_visited:
    return 1

  ret=0
  for i in range(n):
    if visited[i]:
      continue
    if graph[i][v]==False:
      continue
    visited[i]=True
    ret+=dfs(n,i,visited)
    visited[i]=False

  return ret

def main():
  n,m=LI()
  for _ in range(m):
    a,b=LI()
    a-=1
    b-=1
    graph[a][b]=True
    graph[b][a]=True

  visited=[False]*n
  visited[0]=True
  return dfs(n,0,visited)

# main()
print(main())


Measured memory_bytes: 5428
#define MyDebug
#include <bits/stdc++.h>

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)

#ifdef MyDebug
	#define debug(x) cerr << #x << " : " << x << endl
	#define debugP(x) cerr << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

void solve() {
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  val c = Math.cos(Math.PI/3)
  val s = Math.sin(Math.PI/3)

  def getPoints(list:IndexedSeq[(Double,Double)],i:Int):IndexedSeq[(Double,Double)]  =
    if(i==0) list
    else
      getPoints( for{
        k<-0 until list.length-1; i = list(k); j = list(k+1)
        p1 = ((i._1*2+j._1)/3,(i._2*2+j._2)/3)
        p2 = ((i._1+j._1*2)/3,(i._2+j._2*2)/3)
        x = (p2._1-p1._1)*c-(p2._2-p1._2)*s+p1._1
        y = (p2._1-p1._1)*s+(p2._2-p1._2)*c+p1._2
        list2 = if(k==0) Iterator(i,p1,(x,y),p2,j) else Iterator(p1,(x,y),p2,j)
        q<-list2
      } yield q , i-1)

  def main(args:Array[String]) = {
    val n = readInt
    val list = getPoints(IndexedSeq((0D,0D),(100D,0D)),n)
    println(list.map(s=>s._1+" "+s._2).mkString("\n"))
  }
}

Measured memory_bytes: 51436
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
}
int main(){
   Fast_IO();
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   while(k){
      if(c<=a){
         c*=2;
         k--;
      }
      else if(b<=a){
         b*=2;
         k--;
      }
      else if(c<=b){
         c*=2;
         k--;
      }
      else if(b<=a){
         b*=2;
         k--;
      }
      else if(a<b && b<c) break;
   }
   if(a<b && b<c) CC("Yes");
   else CC("No");
}

Measured memory_bytes: 3512
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<algorithm>
using namespace std;
int n;
char x[5010];
int y[5010][5010];
int main()
{
	int i,k,max=0;
	cin>>n;
	cin>>x;
	for(i=1;i<=n;i++)
		for(k=1;k<=n;k++)
		{
			if(i==k)
				continue;
			if(x[i-1]==x[k-1])
				y[i][k]=1+y[i-1][k-1];
			if(y[i][k]>max&&i<k-y[i][k]+1)
				max=y[i][k];
		}
	printf("%d\n",max);
	return 0;
}

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

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

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if ((double)A.at(i) >= (double)sum / (double)M * 0.25) {
            cnt++;
        }
    }

    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
const int maxn=1e5+10;
int n,m,a[maxn];
namespace sub1{
	IL bool check(){
		rep(i,1,m)if(a[i]&1)return false;
		return true;
	}
	IL void work(){
		rep(i,1,m)printf("%d ",a[i]);
		putchar('\n');
		vector<int>b;
		b.pb(1);
		rep(i,1,m-1)b.pb(a[i]);
		b.pb(a[m]-1);
		printf("%d\n",b.size());
		rep(i,0,b.size()-1)printf("%d ",b[i]);
	}
}
namespace sub2{
	IL bool check(){
		int cnt=0;
		rep(i,1,m)if(a[i]&1)cnt++;
		return cnt==1;
	}
	IL void work(){
		int pos;
		rep(i,1,m)if(a[i]&1)pos=i;
		swap(a[m],a[pos]);
		rep(i,1,m)printf("%d ",a[i]);
		putchar('\n');
		vector<int>b;
		b.pb(1);
		rep(i,1,m-1)b.pb(a[i]);
		if(a[m]!=1)b.pb(a[m]-1);
		printf("%d\n",b.size());
		rep(i,0,b.size()-1)printf("%d ",b[i]);
	}
}
namespace sub3{
	IL bool check(){
		int cnt=0;
		rep(i,1,m)if(a[i]&1)cnt++;
		return cnt==2;
	}
	IL void work(){
		int pos;
		rep(i,1,m)if(a[i]&1)pos=i;
		swap(a[1],a[pos]);
		rep(i,2,m)if(a[i]&1)pos=i;
		swap(a[m],a[pos]);
		rep(i,1,m)printf("%d ",a[i]);
		putchar('\n');
		vector<int>b;
		b.pb(a[1]+1);
		rep(i,2,m-1)b.pb(a[i]);
		if(a[m]!=1)b.pb(a[m]-1);
		printf("%d\n",b.size());
		rep(i,0,b.size()-1)printf("%d ",b[i]);
	}
}
int main(){
#ifdef LOCAL
	freopen("/home/noilinux/Desktop/input.txt","r",stdin);
#endif
	n=gi(),m=gi();
	rep(i,1,n)a[i]=gi();
	if(sub1::check())sub1::work();else if(sub2::check())sub2::work();
	else if(sub3::check())sub3::work();else printf("Impossible\n");
	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void solve() {
    ll N;
    cin >> N;
    auto mp = prime_factor(N);
    int ans = 0;
    for(auto &it: mp) {
        int w = 1;
        int s = it.second;
        while((s - w) >= 0) {
            s -= w;
            w++;
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }
    else if(abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------


-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */

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

	LL N, K; cin >> N >> K;
	VL fact(1010, 0);
	fact[0] = 1;
	FOR(i, 1, 1010) {
		fact[i] = i * fact[i - 1];
		fact[i] %=MOD;
	}
	LL ans = 1;
	if (N <= K) {
		FOR(i, 0, N) {
			ans *= K-i;
			ans %= MOD;
		}
	}
	else ans = 0;


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3220
n = int(input())
##実装ミスをあとでミスっていたことが分かるよう修正した結果a,b逆。
##要注意
b = list(map(int, input().split( )))
a = list(map(int,input().split( )))

#これでx考慮しなくてよくなる
a2 = [a[i]^a[i-1] for i in range(n)]
b2 = [b[i]^b[i-1] for i in range(n)]
b2 = b2+b2
#print(a2)
#print(b2)

#ローリングハッシュ
#https://tjkendev.github.io/procon-library/python/string/rolling_hash.html

base = 37; mod = 10**9 + 9
pw = None
def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + s[i]) % mod
    return h
# RH前に、必要な長さの最大値分のpow-tableを計算しておく
def setup_pw(l):
    global pw
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
def get(h, l, r):#lは含まない
    return (h[r] - h[l] * pw[r-l]) % mod

setup_pw(n*2)
bh = rolling_hash(b2)
ah = rolling_hash(a2)
ans = []

get_a = get(ah,0,n)
for k in range(n):
    if get(bh,k,k+n) == get_a:
        ans.append(k)
for k in ans:
    x = b[k]^a[0]
    print(k,x)


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

int n;
const int maxn = 2e5+5;
ll a[maxn],b[maxn],s=0;
map<int,int> mp;
int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		s ^= a[i];	
	}
	for (int i=1;i<=n;i++){
		b[i] = s^a[i];
		cout << b[i] << ' ';	
	}
	return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n;
  cin >> n;
  vector<ll>plus,minus;
  rep(i,n){
    ll a;
    cin >> a;
    if(0<=a)plus.push_back(a);
    else minus.push_back(a);
  }
  sort(all(plus),greater<ll>());
  sort(all(minus));
  if(minus.empty()) minus.push_back(plus.back()), plus.pop_back();
  if(plus.empty()) plus.push_back(minus.back()), minus.pop_back();
  
  vector<P>ans;
  ll now= minus[0];
  
  rep(i,plus.size()-1){
    ans.push_back(P(now,plus[i]));
    now-=plus[i];
  }
  ans.push_back(P(plus.back(),now));
  now=plus.back()-now;
  
  rep(i,minus.size()-1){
    ans.push_back(P(now,minus[i+1]));
    now-=minus[i+1];
  }
  
  cout << now << endl;
  rep(i,n-1){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  
    
  return 0;     
}


Measured memory_bytes: 5104
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=16;
long long arr[N];
int a[N],b[N];
vector<double> slope;
bool bo[N];
int main()
{


/*

int n,x,y;
cin>>n>>x>>y;
for(int i=0;i<n;i++){

    cin>>a[i]>>b[i];
bo[i]=true;


}
int counter=0;
for(int i=0;i<n;i++){

if(bo[i]==false)continue;
    double res=(b[i]-y)*(a[i]-x);


    for(int j=0;j<n;j++){

        if(i!=j ) {

            if(res==((b[j]-y)*(a[j]-x))) {bo[j]==false; bo[i]=false; }


            }



        }
        counter++;

    }




cout<<counter;

*/


vector<long long>vc;

long long n;
cin>>n;

for(long long int i=1;i*i<=n;i++){

    if(n%i==0)vc.push_back(i);
}
long long res=10e13;

for(long long int i=0;i<vc.size();i++){

    res=min(res,abs(vc[i]-1+(n/vc[i])-1));

}

cout<<res;










}


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

int main()
{
	int x , y ;

	for ( int i = 1;; i++ )
	{
		cin >> x >> y;
		
		if ( x == 0 && y == 0 ) break;
		if ( x > y )
		swap ( x , y );
	cout << x << " " << y << endl; 
	}

}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    while(cin >> n, n){
        vector<int> num;
        for(ll i = 2; i*i <= n; i++){
            int t = 0;
            while(n%i == 0) n /= i, t++;
            if(t)   num.push_back(t);
        }
        if(n != 1)  num.push_back(1);
        ll ans = 1;
        for(int t : num){
            ans *= 2*t+1;
        }
        cout << (ans+1)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
from collections import deque
import numpy as np

H,W = [int(zz) for zz in input().split()]
map = [['#']*(W+2) for _ in range(H+2)]

ans = 0
for i in range(1,H+1):
    tmp = input()
    s = list('#'+tmp+'#')
    map[i] = s
    ans += tmp.count('#')

check = [[1]*(W+2) for _ in range(H+2)]
count = [[0]*(W+2) for _ in range(H+2)]
q = deque([(1,1)])
check[1][1] = 0
while q:
    x,y = q.popleft()
    for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
        if check[x+i][y+j] and map[x+i][y+j] == '.':
            check[x+i][y+j] = 0
            q.append((x+i,y+j))
            count[x+i][y+j] = count[x][y]+1
zz = count[H][W]
if zz == 0:
    print(-1)
else:
    count = set((np.array(count)).flatten())
    for i in count:
        if i > zz:
            ans -= 1
    print(H*W-len(count)-ans)


Measured memory_bytes: 14416
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var c = int.Parse(_[2]);

            if(c >= a && c <= b){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long  N;
	long long ans = 0;

	cin >> N;

	for(int i=1; ; i++) {
		// cout << "[i] " << i << endl;
		long long diff = N - i;
		long long dv = diff / i;
		long long mdl = diff % i;
		if(dv > i) {
			if(mdl == 0) {
				ans += dv;
			}
		} else {
			break;
		}
	}

	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt += 1
        elif a % 2 == 0:
            cnt += .5
    print('Yes' if N // 2 <= int(cnt) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19784
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
  ab[i].append(ab[i][0]+ab[i][1])
ab = sorted(ab,key = lambda x:x[2],reverse = True)
ans = 0
for i in range(n):
  if i %2 == 0:
    ans += ab[i][0]
  else:
    ans -= ab[i][1]
print(ans)

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

#define MAX_N 200001
int N;
int A[MAX_N];
int B[MAX_N];

int basis(int k){
    return B[(k+1)%N] + B[(k+N-1)%N];
}

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

    vector<int>flag(N, 0); // 確定したら1
    queue<int> que;
    for (int i = 0; i < N; ++i) {
        que.push(i);
        if(A[i] == B[i]) flag[i] = 1;
    }
    ll ans = 0;
    while (! que.empty()){
        int top = que.front();
        que.pop();
        if(flag[top] == 1) continue;
        int ba = basis(top);
        if(ba > B[top]) continue;
        if((B[top] - A[top]) % ba == 0){
            ans += (B[top] - A[top]) / ba;
            B[top] = A[top];
            flag[top] = 1;
        } else{
            ans += B[top] / ba;
            B[top] %= ba;
            if(B[top] < A[top]){
                cout << -1 << "\n";
                return 0;
            }
        }
        que.push((top+1)%N);
        que.push((top+N-1)%N);
    }
    for (int i = 0; i < N; ++i) {
        if(flag[i] == 0) {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3456
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	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 result = 0;
		int MOD = 1000000007;
		Combination comb = new Combination(r2+c2+2);
		result += comb.combination(r2+c2+2, c2+1)-1;
		result %= MOD;
		result -= comb.combination(r2+c1+1, c1)-1;
		result %= MOD;
		result -= comb.combination(r1+c2+1, r1)-1;
		result %= MOD;
		result += comb.combination(r1+c1, c1)-1;
		result %= MOD;
		if(result < 0) result += MOD;
		
		// 出力
		System.out.println(result);
	}
}

class Combination {
    static final int MOD = 1000000007;
    long[] fact;
    long[] invFact;
    long[] inv;
    
    public Combination (int n) {
        fact = new long[n+1];
        invFact = new long[n+1];
        inv = new long[n+1];
        fact[0] = 1;
        fact[1] = 1;
        invFact[0] = 1;
        invFact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n+1; i++) {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            invFact[i] = invFact[i - 1] * inv[i] % MOD;
        }
    }
    
    public long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) {
            return 0;
        }
        return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
    }
}


Measured memory_bytes: 68436
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    bool f[2<<15];
    fill_n(f,2<<15,true);
    f[0]=f[1]=false;
    for(int i=2;i<1<<15;i++){
        if(!f[i])continue;
        for(int j=i*i;j<1<<15;j+=i)f[j]=false;
    }
    int n;
    while(scanf("%d",&n),n){
        int cnt=0;
        for(int i=2;i<=n/2;i++){
            if(f[i]&&f[n-i])cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1092
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    unsigned long long i,j,a,b;
    cin >> i >>j >> a >> b;
    if((a*b>=(i*j)))
    {
        cout << a*b << endl;
    }
    else
    {
        cout << i*j << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        int[] ary = ToIntArray(input.ReadLine(), n);

        int sum = 0;
        for(int i=0; i<n; i++) {
            for(int j=i; j<n; j++) {
                if (j != i) sum += ary[i] * ary[j];
            }
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
r, c = map(int, input().split())
input_list = [[0 for i in range(c)] for j in range(r)]

for i in range(r):
    input_list[i] = list(map(int, input().split()))
    
for i in range(r):
    for j in range(c):
        if j == 0:
            print(input_list[i][j], sep="", end="")
        else:
            print(" ", input_list[i][j], sep="", end="")
    print(" ", sum(input_list[i]), sep="")

all_sum = 0
for j in range(c):
    tmp_sum = 0
    for i in range(r):
        tmp_sum += input_list[i][j]
    
    if j == 0:
        print(tmp_sum, sep="", end="")
    else:
        print(" ", tmp_sum, sep="", end="")
    
    all_sum += tmp_sum
print(" ", all_sum, sep="")



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

template<class T> struct SegmentTree {
    using F = function<T(T, T)>;
private :
    int n;          // size
    T id;           // identity element
    vector<T> node; // data
    F f;            // operation
    F g;            // update
public :
    // sz : size, f : operation, g : update, def : identity
    SegmentTree(int sz, F f, F g, T id) : n(1), f(f), g(g), id(id) {
        while (n < sz) n *= 2;
        node = vector<T>(2*n-1, id);
    }

    // v : vector, f : operation, g : update, def : identity
    SegmentTree(vector<T> v, F f, F g, T id) : n(1), f(f), g(g), id(id) {
        while (n < (int)v.size()) n *= 2;
        node = vector<T>(2*n-1, id);
        for (int i = 0; i < (int)v.size(); i++) node[i+n-1] = v[i];
        for (int i = n-2; i >=0; i--) node[i] = f(node[i*2+1], node[i*2+2]);
    }

    // update
    void update (int i, T x) {
        i += n - 1;
        assert(i < node.size());
        node[i] = g(node[i], x);
        while (i > 0) {
            i = (i-1)/2;
            node[i] = f(node[2*i+1], node[2*i+2]);
        }
    }

    // query [a, b)
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }

    T query (int a, int b) { return query(a, b, 0, 0, n); }

};

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    
    auto id = [](char c) { return c - 'a'; };
    auto f = [](int a, int b) { return a + b; };
    auto g = [](int a, int b) { return b; };
    vector<SegmentTree<int>> seg(30, SegmentTree<int>(n+10, f, g, 0));
    for (int i = 0; i < n; i++) seg[id(s[i])].update(i, 1);
    
    while (q--) {
        int op;
        cin >> op;
        if (op == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            seg[id(s[i])].update(i, 0);
            s[i] = c;
            seg[id(s[i])].update(i, 1);
        } else {
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                if (seg[i].query(l, r) > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 90000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

int a,b,q;
ll s[100005],t[100005];

int lows(ll tar){
    int low=0,high=a+1;

    while (low<high){
        int mid=(low+high+1)/2;

        if (s[mid]<=tar) low=mid;
        else high=mid-1; 
    }

    return low;
}

int lowt(ll tar){
    int low=0,high=b+1;

    while (low<high){
        int mid=(low+high+1)/2;

        if (t[mid]<=tar) low=mid;
        else high=mid-1; 
    }

    return low;
}

int his(ll tar){
    int low=0,high=a+1;

    while (low<high){
        int mid=(low+high)/2;

        if (s[mid]>=tar) high=mid;
        else low=mid+1; 
    }

    return high;
}

int hit(ll tar){
    int low=0,high=b+1;

    while (low<high){
        int mid=(low+high)/2;

        if (t[mid]>=tar) high=mid;
        else low=mid+1; 
    }

    return high;
}

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

    cin >> a >> b >> q;

    for (int i=1;i<=a;i++){
        cin >> s[i];
    }

    for (int i=1;i<=b;i++){
        cin >> t[i];
    }
    s[0]=-MOD;t[0]=-MOD;
    s[a+1]=MOD;t[b+1]=MOD;

    while (q--){
        ll query;
        cin >> query;

        int sa=lows(query),sb=his(query);
        int ta=lowt(query),tb=hit(query);

        ll ans=max(s[sb],t[tb])-query;
        ans=min(ans,query-min(s[sa],t[ta]));
    //    cerr << ans << el << el;;
    //    cerr << s[sa] << " " << s[sb] << " " << t[ta] << " " << t[tb] << el;
        ans=min(ans,s[sb]-t[ta]+min(s[sb]-query,query-t[ta]));
        ans=min(ans,t[tb]-s[sa]+min(t[tb]-query,query-s[sa]));

        cout << ans << el;
    }

    return 0;
}


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

int main() {
  int a[5] = {0, 6000, 4000, 3000, 2000};
  for (int i = 0; i < 4; ++i) {
    int t, n;
    cin >> t >> n;

    cout << n * a[t] << endl;
  }
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    int one_keta = N % 10;
    
    if(one_keta == 3){
        cout << "bon" << endl;
    }
    else if(one_keta == 0 || one_keta == 1 || one_keta == 6 || one_keta == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    
    
}


Measured memory_bytes: 3024
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  int a,b,c,k,ans;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a>=b && a>=c){
    ans=a*pow(2,k)+b+c;
    printf("%d",ans);
  }
  else if(b>=c && b>=a){
    ans=b*pow(2,k)+a+c;
    printf("%d",ans);
  }
  else{
    ans=c*pow(2,k)+a+b;
    printf("%d",ans);
  }

	return 0;
}


Measured memory_bytes: 128
//-----------------------
// author : xyqkoala
// time : 2020-08-15
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	string s;
	cin>>s;
	int cnt = 0;
	int  n = s.size();
	int res = 0;
	for(int i=0;i<=n;i++){
		if(i==n || s[i]=='S'){
			res = max(res,cnt);
			cnt = 0;
		}else{
			cnt++;
		}
	}
	cout<<res<<endl;
}


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

typedef long long LL;

const int N=200000;

int n,a[N+9];

int main(){
  scanf("%d",&n);
  LL sum=0;
  for (int i=0;i<=n;++i){
	scanf("%d",&a[i]);
	sum+=a[i];
  }
  if (n==0) {puts(a[0]==1?"1":"-1");return 0;}
  if (a[0]) {puts("-1");return 0;}
  LL now=1,ans=1;
  for (int i=1;i<=n;++i){
	ans+=now=min(now<<1,sum);
	if ((now-=a[i])<0) {puts("-1");return 0;}
	sum-=a[i];
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 4228
import math
n, m = map(int, input().split())
a = list(float(x) for x in input().split())
a.sort(reverse=True)
while m > 0:
    for i in range(n):
        if a[i] >= a[0]:
            a[i] = a[i] / 2
            m -= 1
            if m == 0:
                break
        else:
            a.sort(reverse=True)
            break
ans = 0
for i in range(n):
    ans += int(math.floor(a[i]))
print(ans)

Measured memory_bytes: 14252
fun main(args: Array<String>) {
    keyence2019b()
}

fun keyence2019b() {
    val s = readLine()!!
    val keyence = "keyence"

    for (subStart in s.indices) {
        for (subEnd in s.indices) {
            if (s.slice(0..subStart) + s.slice(subEnd..s.lastIndex) == keyence) {
                return println("YES")
            }
        }
    }

    println("NO")
}


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

bool ok(int n, bool f[11]) {
	while(n > 0) {
		int x = n%10;
		if(f[x]) return false;
		n /= 10;
	}
	return true;
}
int main() {
	bool banned[11]{false};
	int num;
	int k;
	cin >> num >> k;
	for(int i = 1; i <= k; ++i) {
		int x;
		cin >> x;
		banned[x] = true;
	}
	while(!ok(num, banned)) ++num;
	cout << num;
	
}

Measured memory_bytes: 256