akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;


int main()
{
	int h,w;
	cin >> h >> w;
	char a[h][w];
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}
	int deleteRow[h];
	int rowCount = 0;
	for (int i = 0; i < h; i++)
	{
		bool allWhite = true;
		for (int j = 0; j < w; j++)
		{
			if (a[i][j] == '#') allWhite = false;
		}
		if (allWhite)
		{
			deleteRow[rowCount] = i;
			rowCount++;
		}
	}
	int deletecol[w];
	int colcount = 0;
	for (int j = 0; j < w; j++)
	{
		bool allWhite = true;
		for (int i = 0; i < h; i++)
		{
			if (a[i][j] == '#') allWhite = false;
		}
		if (allWhite)
		{
			deletecol[colcount] = j;
			colcount++;
		}
	}
	for (int i = 0; i < h; i++)
	{
		bool show = true;
		bool shown = true;
		for (int p = 0; p < rowCount; p++)
		{
			if (i == deleteRow[p]) show = false;
		}
		for (int j = 0; j < w; j++)
		{
			bool show2 = true;
			for (int q = 0; q < colcount; q++)
			{
				if (j == deletecol[q]) show2 = false;
			}
			if (show && show2) cout << a[i][j];

		}
		if (show) cout<< endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};
template<typename T> ll comb(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}

/* ここからコード開始 */

int main(){
  kyopro;
  ld N;
  cin >> N;
  ld sum{};
  rep(i, 0, N){
    ld x;
    string u;
    cin >> x >> u;
    if(u == "JPY") sum += x;
    else if(u == "BTC") sum += x * 380000;
  }
  cout << sum << rt;
}

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

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

using ll = long long;
using namespace std;

int
main ()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(n, i) {
      cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<>());

    auto sum = 0ll;
    rep(n, i) {
      if ( i < k ) continue;
      sum += h[i];
    }
    cout << sum << endl;
}


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

using namespace std;

int N, arr[10004];
vector < int > way[10004];
int C[10004], bw[10004], chk[10004];
vector < int > sun;

void sol(int num){
    chk[num] = 1;
    for(auto&nxt:way[num]) if(!chk[nxt]){
        sol(nxt);
    }
    sun.push_back(num);
}

int main(){
    scanf("%d", &N);
    for(int i = 1; i < N; ++i){
        int a, b; scanf("%d %d", &a, &b);
        way[a].push_back(b), way[b].push_back(a);
    }
    for(int i = 1; i <= N; ++i) scanf("%d", C + i);
    sort(C + 1, C + N + 1);
    sol(1);
    if((int)sun.size() < N){
        sun.push_back(1);
    }
    for(int i = 0; i < N; ++i){
        arr[sun[i]] = C[i + 1];
    }
    int ans = 0;
    for(int i = 1; i <= N; ++i){
        for(auto&j:way[i]){
            ans += min(arr[i], arr[j]);
        }
    }
    ans /= 2;
    printf("%d\n", ans);
    for(int i = 1; i <= N; ++i){
        printf("%d ", arr[i]);
    }
    return 0;
}


Measured memory_bytes: 1536
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n;
	string s;
	cin>>n>>s;
	REP(i,SZ(s)){
		s[i]='A'+(s[i]-'A'+n)%26;
	}
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    lvec a(n);rep(i,n) cin>>a[i];
    ll ans=1000000000;
    sort(all(a));
    for(int i=a[0];i<=a[n-1];i++){
        ll cnt=0;
        for(int j=0;j<n;j++){
            ll p=1;
            for(int k=0;k<2;k++){
                p*=a[j]-i;
            }
            cnt+=p;
        }
        if(cnt<ans) ans=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

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

    return arr
N = int(input())
if N==1:
    print(0)
    sys.exit(0)

s = factorization(N)
ans = 0
for i,j in s:
    k = 1
    while j-k>=0:
        j -= k
        k += 1
        ans += 1
print(ans)

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

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

    ll n,m;cin>>n>>m;
    vector<ll> ary(n), s(n+1);
    rep(i,n) cin >> ary[i];
    sort(ary.begin(), ary.end());
    rep(i,n) s[i+1] = s[i]+ary[i];
    ll ok = 0;
    ll ng = 1e6;
    while(ng-ok>1)
    {
        ll mid = (ok+ng)/2;
        ll num = 0;
        rep(i,n)
        {
            num += ary.end() - lower_bound(ary.begin(), ary.end(), mid - ary[i]);
        }
        (num >= m ? ok : ng) = mid;
    }
    ll ans = 0, num=0;
    rep(i,n)
    {
        ll amari = lower_bound(ary.begin(), ary.end(), ok-ary[i]) - ary.begin();
        ans += s[n] - s[amari];
        ans += (n-amari) * ary[i];
        num+=n-amari;
    }
    // 余剰分を引いている
    ans += ok * (m-num);
    cout << ans << endl;

}

Measured memory_bytes: 1792
n = gets.to_i
a = gets.split.map(&:to_i)
suma = 0
a.each do |i|
  suma += i
end
min = 1e10
tmp = 0
(n-1).times do |i|
  tmp += a[i]
  if min > (suma-2*tmp).abs
    min = (suma-2*tmp).abs
  end
end
puts min


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

using namespace std;
#define BUF (1000)

char s[4];
int A,B,C,D;

int main(void){
	cin >> s;
	A = s[0]-0x30;
	B = s[1]-0x30;
	C = s[2]-0x30;
	D = s[3]-0x30;

	int ans;
	for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++){
		ans = A + (2*i-1)*B + (2*j-1)*C + (2*k-1)*D;
		if(ans==7){
			cout << A;
			i==0 ? cout << "-" : cout << "+";
			cout << B;
			j==0 ? cout << "-" : cout << "+";
			cout << C;
			k==0 ? cout << "-" : cout << "+";
			cout << D << "=7\n"; 
			return 0;
		}
	}	
	return 0;
}

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

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

    vector<int> A(101010);
    rep(i,n){
        int a;
        cin>>a;
        A[a]++;
    }

    int ans=0;
    rep(i,101010){
        ans=max(ans,A[i]+A[i+1]+A[i+2]);
    }
    cout<<ans<<endl;
    
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind {
  vector<int> data;
  UnionFind(){}
  void init(int n) {
    data.clear();
    data.resize(n, -1);
  }
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y]; data[y] = x;
  }
};

struct edge {
  int u, v, w, id;
  edge(){}
  edge(int u, int v, int w, int id):u(u), v(v), w(w), id(id){}
  bool operator < (const edge& e) const {
    return w < e.w;
  }
};

int N, M;
vector<edge> E;
vector<int> used;
int weight;
UnionFind uf;

int Kruskal(int id = -1) {
  uf.init(N);
  int res = 0;
  for(auto e : E) {
    if(e.id == id) {
      weight = e.w;
      continue;
    }
    if(!uf.same(e.u, e.v)) {
      uf.unite(e.u, e.v);
      res += e.w;
      if(id == -1) used.push_back(e.id);
    }
  }
  if(uf.size(0) < N) return inf;
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  rep(i, M) {
    int s, d, c;
    cin >> s >> d >> c;
    --s, --d;
    E.emplace_back(s, d, c, i);
  }
  sort(all(E));
  int mn = Kruskal();
  int ans = 0, cost = 0;
  for(int i : used) {
    if(Kruskal(i) > mn) ans++, cost += weight;
  }
  cout << ans << " " << cost << endl;

  return 0;
}

Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1; } return 0;}
const long long INF = 1LL << 60;

int main(){
  int N, W;
  cin >> N >> W;
  vector<long long> value(110), weight(110);
  for(int i= 1; i <= N; i++){
    cin >> weight[i] >> value[i];
  }
  int MAX_V = 100100;
  vector<vector<long long>> dp(N + 1, vector<long long> (MAX_V, INF));
  dp[0][0] = 0;
  for(int i = 1; i <= N; i++){
    for(int sum_v = 0; sum_v <= MAX_V; sum_v++){
      if(sum_v  - value[i] >= 0){
        chmin(dp[i][sum_v], dp[i - 1][sum_v - value[i]] + weight[i]);
      }
      chmin(dp[i][sum_v], dp[i - 1][sum_v]);
    }
  }
  long long ans = 0;
  for(int i = 1;  i < MAX_V; i++){
    if(dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        while (a> 0 && c>0){
            c = c - b;
            if (c<=0){
                break;
            }
            a = a - d;
        }
        if (c<= 0 )
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 27000
mod = (10 ** 9) + 7
lim = 1100000

fct = [0] * lim
inv_f = [0] * lim

fct[0] = 1
for i in range(1, lim):
    fct[i] = fct[i - 1] * i % mod

inv_f[lim - 1] = pow(fct[lim - 1], mod - 2, mod)

for i in range(lim - 1, 0, -1):
    inv_f[i - 1] = inv_f[i] * i % mod


def nCk(a, b):
    if a < b:
        return 0
    else:
        return fct[a] * inv_f[b] * inv_f[a - b] % mod


n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()

s_max = 0
s_min = 0

for i in range(k - 1, n):
    s_max = s_max + s[i] * nCk(i, k - 1)
    s_max %= mod

for i in range(n - k + 1):
    s_min = s_min + s[i] * nCk(n - i - 1, k - 1)
    s_min %= mod

print((s_max-s_min) % mod)
# print(s_max, s_min)


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

class Program {
    static void Main(string[] args) {
        int N, K;
        Input(out N, out K);
        long[] H;
        InputArray(out H);
        Array.Sort(H);
        Array.Reverse(H);
        long sum = 0;
        for(int i = K; i < N; i++) {
            sum += H[i];
        }
        Console.WriteLine(sum);
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

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

typedef long long ll;

ll n, cnt, d[1000005];
ll cnt2, d2[1000005];

int main()
{
	scanf("%lld", &n);
	for(ll i = 1; i * i <= (n - 1); ++i) {
		if((n - 1) % i == 0) {
			d[++cnt] = i;
			if(i * i != n - 1) d[++cnt] = (n - 1) / i;
		}
	}
	
	for(ll i = 1; i * i <= n; ++i) {
		if(n % i == 0) {
			d2[++cnt2] = i;
			if(i * i != n) d2[++cnt2] = n / i;
		}
	}
	
	sort(d2 + 1, d2 + cnt2 + 1);
	
	for(int i = 2; i <= cnt2; ++i) {
		ll x = n;
		
		while(x % d2[i] == 0) x /= d2[i];
		if(x % d2[i] == 1) d[++cnt] = d2[i];
	}
	
	sort(d + 1, d + cnt + 1);
	cnt = unique(d + 1, d + cnt + 1) - d - 1;
	
	printf("%lld", cnt - 1);
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    cout << setprecision(16) << fixed;

    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(n), rG(n);
    vector<ll> in(n);
    while(m--) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        rG[y].push_back(x);
        in[y]++;
    }
    
    vector<ll> idx(n), ridx(n);
    {
        ll x = 0;
        queue<ll> q;
        for(ll i=0; i<n; i++)
            if(!in[i]) q.push(i);
        while(!q.empty()) {
            ll i = q.front(); q.pop();
            idx[i] = x++;
            ridx[idx[i]] = i;
            for(ll v: G[i])
                if(!--in[v]) q.push(v);
        }
    }

    vector<ll> dp(n);
    for(ll i=0; i<n; i++)
        for(ll j: rG[ridx[i]])
            dp[i] = max(dp[i], 1 + dp[idx[j]]);

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 14336
import sys
input = sys.stdin.readline


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

for i, p in enumerate(P):
    graph[p-1].append(i+1)

stack = [0]
Scores = [[0, 0] for _ in range(N)]
Ind = [0]*N
ok = True
while stack and ok:
    p = stack[-1]
    if Ind[p] == len(graph[p]):
        stack.pop()
        Max = Xs[p]
        dp = [False]*(Max+1)
        dp[0] = True
        S = 0
        for ch in graph[p]:
            a, b = Scores[ch]
            S += a+b
            for x in reversed(range(Max+1)):
                dp[x] = (x >= a and dp[x-a]) or (x >= b and dp[x-b])
        to_ret = -1
        for x in reversed(range(Max+1)):
            if dp[x]:
                to_ret = S - x
                break
        if to_ret == -1:
            ok = False
        else:
            Scores[p] = [Max, to_ret]
    else:
        stack.append(graph[p][Ind[p]])
        Ind[p] += 1

print("POSSIBLE" if ok else "IMPOSSIBLE")

Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;




int main() {
	int i, j, k;
	ll N, M, K;

	string S, T;
	cin >> S >> T;
	cout << T << S;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

struct UnionFind {

	vi data;

	UnionFind(int n = 0) {
		data.assign(n, -1);
	}

	int find(int k) {
		if (data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int k) { return -data[find(k)]; }

};

int main() {

	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;a--, b--;
		uf.unite(a, b);
	}

	set<int> se;
	rep(i, n)se.insert(uf.find(i));
	cout << se.size() - 1 << endl;

}

Measured memory_bytes: 7560
import sys
from fractions import gcd
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

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

def main():
    N = ii()
    T = [ii() for _ in range(N)]
    ans = 1
    for i in range(N):
        ans = lcm(ans, T[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77512
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int a[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=0x3f3f3f3f;
	for(int t=-100;t<=100;t++)
	{
		int cur=0;
		for(int i=0;i<n;i++)
			cur+=(a[i]-t)*(a[i]-t);
		ans=min(ans,cur);
	}
	cout<<ans<<endl;
}


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

int main(){
    int h,w;	cin >> h >> w;
    vector<vector<char> >a(h+2, vector<char>(w+2, '#'));
    for(int i = 1; i <= h; i++){
	for(int j = 1; j <= w; j++) cin >> a[i][j];
    }
    rep(i, h+2){
	rep(j, w+2) printf("%c", a[i][j]);
	printf("\n");
    }	
}


Measured memory_bytes: 256
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll n,m,f=0;
    cin>>n>>m;

    ll a[n+1];
    for1(i,n) a[i]=-1;

    forn(i,m){
        ll p,q;
        cin>>p>>q;
        if((a[p]!=-1)&&(a[p]!=q)){
           // cout<<a[p];
            //cout<<p<<" "<<q<<"......";
            f=1;
        }
        a[p]=q;
    }
    if((n!=1)&&(a[1]==-1)) a[1]=1;
    for1(i,n)
    if(a[i]==-1) a[i]=0;

    if(n!=1){
        ll j=1;
    for(j=1;j<=n;j++){
        if(a[j]!=0) break;
    }
    if(j!=1) f=1;
    }
    if(f==1) cout<<"-1";
    else for1(i,n) cout<<a[i];
}

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

using namespace std;

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double alpha = (H * 60 + M) / 720 * (M_PI * 2);
    double beta = (M / 60) * (M_PI * 2);
    double theta = alpha - beta;
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));
    cout << fixed << setprecision(9) << ans << endl;

    return 0;
}

Measured memory_bytes: 4228
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
 
def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d
 
a = comb(n, a)
b = comb(n, b)
 
print((pow(2, n, mod) -1 -a -b) % mod)

Measured memory_bytes: 40176
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct Graph{
    struct Node{
        vector<int> dests;
        int color = -1;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    // void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void add1Edge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void add2Edge2(int from, int dest){
        add1Edge(from, dest);
        add1Edge(dest, from);
    }
    bool isBipartile(int idx, int color = 0, int from = -1){
        if(nodes[idx].color == -1){
            nodes[idx].color = color;
        }else{
            return nodes[idx].color == color;
        }
        for(int didx : nodes[idx].dests){
            if(didx == from){ continue; }
            if(!isBipartile(didx, !color, idx)){
                return false;
            }
        }
        return true;
    }
    ll dijkstra(int start, int goal){
        struct DElem{
            int cost, dest;
            bool operator < (const DElem& e) const { return cost > e.cost; }
        };
        priority_queue<DElem> pq;
        pq.push({0, start});
        vector<int> visited(nodes.size());
        while(pq.size()){
            auto e = pq.top(); pq.pop();
            if(visited[e.dest]){ continue; }
            visited[e.dest] = true;
            if(e.dest == goal){
                return e.cost;
            }
            // for(auto& edge : nodes[e.dest].edges){
            //     pq.push({e.cost + edge.cost, edge.dest});
            // }
            for(int didx : nodes[e.dest].dests){
                pq.push({e.cost + 1, didx});
            }
        }
        return -1;
    }
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    // vector<vector<int>> ss(n, vector<int>(n)); cin >> ss;
    Graph g(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            char s; cin >> s;
            if(s == '1' && i < j){
                g.add2Edge2(i, j);
            }
        }
    }
    if(!g.isBipartile(0)){
        cout << -1 << '\n';
        return 0;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int len = g.dijkstra(i, j);
            ans = max(ans, len);
        }
    }
    cout << ans + 1 << '\n';
}


Measured memory_bytes: 856
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int a, b, c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e;
if(a<b){f=a;a=b;b=f;}
if(a<c){f=a;a=c;c=f;}
if(a<d){f=a;a=d;d=f;}
if(a<e){f=a;a=e;e=f;}
if(b<c){f=b;b=c;c=f;}
if(b<d){f=b;b=d;d=f;}
if(b<e){f=b;b=e;e=f;}
if(c<d){f=c;c=d;d=f;}
if(c<e){f=c;c=e;e=f;}
if(d<e){f=d;d=e;e=f;}
cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
return 0;
}

Measured memory_bytes: 1164
# 2つの部分列に分ける
def eqcut(start, end, prev):
    prev_diff = abs(2 * cumA[prev] - cumA[start - 1] - cumA[end])
    for i in range(prev + 1, end + 1):
        diff = abs(2 * cumA[i] - cumA[start - 1] - cumA[end])
        if diff > prev_diff: break
        prev_diff = diff
    return i - 1

N = int(input())
A = [int(x) for x in input().split()]

cumA = [A[0]] + [0] * N  # 累積和  cumA[-1] = 0となるように最後にダミー
for i in range(1, N):
    cumA[i] = cumA[i - 1] + A[i]

S = [0, 0, 0, 0]
B = [0, 0]
ans = cumA[N - 1]
# 3本の境界線のうち中央を探す
for i in range(1, N - 2):
    B[0] = eqcut(0, i, B[0])  # A[0], ..., A[i]を要素の総和が最小となる2つの部分列に分ける
    S[0] = cumA[B[0]]
    S[1] = cumA[i] - cumA[B[0]]

    B[1] = eqcut(i + 1, N - 1, B[1])
    S[2] = cumA[B[1]] - cumA[i]
    S[3] = cumA[N - 1] - cumA[B[1]]

    ans = min(ans, max(S) - min(S))

print(ans)

Measured memory_bytes: 106968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int HM = 60, MS = 60, HS = 60 * 60;

int main()
{
    int hs, hf, ms, mf, ss, sf;
    REP(3)
    {
        cin >> hs >> ms >> ss >> hf >> mf >> sf;
        int ans = (hf - hs) * HS + (mf - ms) * MS + sf - ss;

        cout << ans / HS << " ";
        ans = ans % HS;
        cout << ans / MS << " ";
        ans = ans % MS;
        cout << ans << endl;
    }

    return 0;
}

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

typedef long long vlong;
const int maxn = 55;

int a[maxn];
vlong dp[maxn][101*101], p, n;

vlong knap(int i, int tmp){
	if(i >= n){
		if(tmp % 2 == p)return 1;
		
		else{
			return 0;
		}
	}
	if(dp[i][tmp] == -1){
		vlong ret1 = 0, ret2 = 0;
		ret1 = knap(i+1, a[i]+tmp);
		ret2 = knap(i+1, tmp);
		dp[i][tmp] = ret1 + ret2;
	}
	return dp[i][tmp];
}

int main(int argc, char const *argv[])
{
	cin >> n >> p;
	for(int i = 0;i < n;i++)
		cin >> a[i];

	memset(dp, -1, sizeof dp);
	cout << knap(0, 0) << endl;
}


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

bool p(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.length();
  if (p(s) && p(s.substr(0, n / 2)) && p(s.substr(n / 2 + 1))) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

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

#define pi acos(-1)
int main()
{
    double a,b,c,d;
    cin>>a>>b>>c>>d;

    double ha = .5*(c*60+d);
    double ma = d*6;
    double angle = abs(ha-ma);
    angle = min(360-angle,angle);
    double ans = sqrt(a*a+b*b-2*a*b*cos(angle*pi/180));
    cout<<setprecision(11)<<fixed<<ans<<endl;
}



Measured memory_bytes: 4156
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

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

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<ll,ll,ll,ll> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	while(cin>>n>>m,n|m){
		vi a(n),b(m);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		int sum_a=0,sum_b=0;
		rep(i,n)sum_a+=a[i];
		rep(i,m)sum_b+=b[i];
		int out_a=inf,out_b=inf;
		rep(i,n)rep(j,m)if(sum_a-a[i]+b[j]==sum_b-b[j]+a[i]){
			if(out_a+out_b>a[i]+b[j]){
				out_a=a[i];
				out_b=b[j];
			}
		}
		if(out_a!=inf)cout<<out_a<<" "<<out_b<<endl;
		else cout<<-1<<endl;
		end:;
	}
}

Measured memory_bytes: 3116
#include<iostream>
using namespace std;
 
int main()
{
	int a;
    int b;
    cin >> a;
    cin >> b;
    if(a*b%2==0)
   {
	cout << "Even" << endl;
   }
   else
   {
   cout <<  "Odd" << endl;
   }
       return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll max_v = 1;
  for (int i = 1; i * i <= N; i++) {
    max_v = i * i;
  }
  cout << max_v << endl;
  return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		System.out.println((b-a==c-b)?"YES":"NO");
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define mod(n, m) (((n % m) + m) % m)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    ll sum = 0;
    for(auto c : s)
        sum += (c - '0'), sum %= 9LL;
   // cout << sum << '\n';
    cout << (sum % 9LL ? "No" : "Yes");

}

Measured memory_bytes: 3736
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, M; std::cin >> N >> M;
	std::vector<Int> H(N);
	rep(i, N)std::cin >> H[i];
	std::vector<std::vector<Int>> graph(N);
	rep(i, M) {
		Int A, B; std::cin >> A >> B;
		A--; B--;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}

	Int ans = 0;
	rep(i, N) {
		Int max = -1;
		for (const auto& elem : graph[i]) {
			if (H[elem] > max)max = H[elem];
		}
		if (H[i] > max)ans++;
	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

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

int main(){
	ll n,k,count=1;
	string s;
	cin >> n >> k >> s;
	s = s + '.';

	vector<ll> v,x;

	for(int i=1;i<s.size();i++){
		if(s[i] != s[i-1]){
			v.push_back(count);
			x.push_back( (s[i-1]=='0') );
			count = 0;
		}
		count++;
	}

	vector<ll> vsum(v.size(),v[0]),xsum(x.size(),x[0]);
	for(int i=1;i<x.size();i++){
		vsum[i] = vsum[i-1] + v[i];
		xsum[i] = xsum[i-1] + x[i];
	}

	ll ans = 0;
	for(int i=0;i<x.size();i++){
		ans = max(ans,( xsum[i]<=k ? vsum[i] : vsum[i]-vsum[i-k*2-(x[i]==0)] ));
	}

	cout << ans << endl;

}

Measured memory_bytes: 3688
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  int a;
  int mina=9999;
  int maxa=0;
  cin >> n;
  for(int i = 0;i < n; i++){
    cin >> a;
    mina = min(mina, a);
    maxa = max(maxa, a);
  }
  
  cout << maxa - mina << endl;
  return 0;
}


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

int main(void){
    int arpha[26] = {0};
    int i,len;
    char str[128];
    char *p;
    int chk = 0;

    p = fgets(str, 128, stdin);

    for(i=0;128;i++){
        if(str[i] < 'a' || str[i] > 'z'){
            len=i;
            break;
        }
    }

    for(i=0;i<len;i++){
        arpha[str[i] - 'a']++;
    }

    for(i=0;i<26;i++){
        if(arpha[i] % 2) {
            chk = 1;
            break;
        }
    }

    (chk) ? printf("No\n"):printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int sum = 0;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        sum += a - 1;
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=0
B=0
C=0
D=0
for i in range(N):
    s=input()
    if s=="AC":
        A+=1
    elif s=="WA":
        B+=1
    elif s=="TLE":
        C+=1
    else:
        D+=1

print("AC x", A)
print("WA x", B)
print("TLE x", C)
print("RE x", D)

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n; cin >> h >> w >> n;
	if (h < w) swap(h, w);
	int ans = 0;
	while (n > 0) {
		n -= h; ans++;
	}
	cout << ans << '\n';
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    long long n, q;
    cin >> n >> q;
    vector<long long> num(n, 0);
    long long t = sqrt(n);
    vector<long long> divnum((n + t - 1) / t, 0);
    for(int i = 0; i < q; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        b--;
        if(a == 0){
            num[b] += c;
            divnum[b / t] += c;
        }
        else{
            c--;
            long long low = b / t + 1, up = c / t - 1;
            long long ans = 0;
            for(int j = low; j <= up; j++) ans += divnum[j];
            for(int j = b; j <= min(low * t - 1, c); j++) ans += num[j];
            if(b != max(b, c/t * t) || c != min(low * t - 1, c)){
                for(int j = max(b, c / t * t); j <= c; j++) ans += num[j];
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        ll n,a,b,ans=0,d=0,c=0;
        cin>>n>>a>>b;

        d= n/(a+b);
        if(n%(a+b)!=0)
        	c=n%(a+b);

       

        cout<<d*a +min(c,a);
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int H, W;
int ctr[26];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W;
  rep(i, H) rep(j, W) {
    char c;
    cin >> c;
    ctr[c-'a']++;
  }
  int num_odd = 0;
  rep(i, 26) if (ctr[i] % 2 == 1) num_odd++;
  if (W%2 == 1 && H%2 == 1) {
    // 1のハコがある
    if (num_odd != 1) {
      cout << "No\n";
      return 0;
    }
    rep(i, 26) if (ctr[i] % 2 == 1) ctr[i]--;
  }
  else {
    if (num_odd != 0) {
      cout << "No\n";
      return 0;
    }
  }
  rep(i, 26) assert(ctr[i]%2==0);
  rep(i, 26) ctr[i]/=2;
  int two = 0;
  rep(i, 26) two += ctr[i]/2;
  if (two < (W/2) * (H/2)) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#define debug cout

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int bar[20];

int main() {
	int n,w;
	IL{
		cin>>n>>w;
		if(n==0&&w==0)break;
		memset(bar,0,sizeof(bar));
		int xm=0,ym=0;
		rep(i,n){
			int v;
			cin>>v;
			++bar[v/w];
			chmax(xm,v/w);
		}
		rep(i,xm+1){
//debug<<bar[i]<<endl;
			chmax(ym,bar[i]);
		}
//debug<<xm<<" "<<ym<<endl;
		double res=0.01;
		rep(i,xm){
			res+=(double)bar[i]/ym*(1-(double)i/xm);
		}
		printf("%.12f\n",res);
	}
	return 0;
}

Measured memory_bytes: 0
#include<complex>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
const int N=2e5+7,M=2e3+7;
int n,ans,maxn;
int a[N],b[N];
long long f[M<<1][M<<1],fac[M<<2],fdiv[M<<2],num[M<<2];
int qread()
{
	int x=0;
	char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int C(int n,int m)
{
	return fac[n]*fdiv[m]%mod*fdiv[n-m]%mod;
}
void Init()
{
	fac[0]=fdiv[0]=fdiv[1]=num[1]=1;
	for(int i=1;i<=maxn;i++)
		fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=maxn;i++)
	{
		num[i]=(mod-mod/i)*num[mod%i]%mod;
		fdiv[i]=fdiv[i-1]*num[i]%mod;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		a[i]=qread();b[i]=qread();
		maxn=max(maxn,a[i]+b[i]<<1);
		f[M-a[i]][M-b[i]]++;
	}
	Init();
	for(int i=1;i<=n;i++)
		ans=(ans-C(a[i]+b[i]<<1,a[i]<<1)+mod)%mod;
	for(int i=1;i<M*2;i++)
		for(int j=1;j<M*2;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;i++)
		ans=(ans+f[a[i]+M][b[i]+M])%mod;
	printf("%d\n",ans*fdiv[2]%mod);
	return 0;
}

Measured memory_bytes: 127744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  ll L[90];
  L[0] = 2;
  L[1] = 1;
  int N;
  cin >> N;
  for(int i = 2; i <= N; ++i){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[N] << endl;
}


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

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

	if(S == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	
	return 0;
}

Measured memory_bytes: 3588
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, K = MAP()

s = [0] * N
d, A = [], []
for i in range(K):
    d = INT()
    ai = LIST()
    for aii in ai:
        s[aii-1] += 1

print(s.count(0))


    

Measured memory_bytes: 67616