akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
ull Gcd(ull a, ull b){
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	while (a %= b ^= a ^= b ^= a);

	return b;
}
ull Lcm(ull x, ull y){
	return x* (y/Gcd(x,y));
}
int main()
{
	
	int n;
	cin >> n;
	ull ans = 0;
	for (int i = 0; i < n; i++){
		ull a;
		cin >> a;
		if (!i)
			ans = a;
		else ans = Lcm(ans, a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int H, W;
vector<long> v;
int main(){

	while (true){
		cin >> H >> W;
		if (H + W == 0)break;

		for (int y = 0; y < H; ++y){
			for (int x = 0; x < W; ++x){
				if (y > 0 && y < H - 1 && x > 0 && x < W - 1){
					cout << ".";
				}
				else{
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

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

bool check(char a, char b){
  return (a == '1' && b == '0') || (a == '0' && b == '1');
}

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

  int sum = 0;
  int crr = 0;
  while( crr <= s.length() - 1 && s.length() > 0 ){
    while (check(s[crr], s[crr+1]) ){
      s.erase(crr, 2);
      sum += 2;
      crr = max(0, crr - 1);
    }
    crr ++;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int n, k; cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		if (n - k < i - 1) {
			cout << 0 << endl; continue;
		}
		int p = comb(k - 1, i - 1);
		int ko = n - k - (i - 1);
		int q = comb(i + ko, i);
		cout << p * q % mod << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int p, int q) {
    while (q != 0) {
      int r = p % q;
      p = q; 
      q = r;
    }
    return p;
}
  
int main(){
    int k;
    scanf("%d", &k);
    long sum = 0;
    
    for (int a = 1; a <= k; a++)
      for (int b = 1; b <= k; b++)
        for (int c = 1; c <= k; c++)
          sum += gcd(gcd(a, b), c);
    
    printf("%ld", sum);
    return 0;
 }


Measured memory_bytes: 1684
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    std::string S, T;
    std::cin >> S >> T;
    int cnt = S.size();
    int n = T.size();
    for(int i = 0; i + n - 1 < S.size(); i++){
        int tmp = 0;
        for(int j = 0; j < n; j++){
            if(S[i + j] != T[j]){
                tmp++;
            }
        }
        cnt = std::min(cnt, tmp);
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 1000000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int k = a;
	a = b;
	b = k;
	k = a;
	a = c;
	c = k;
	cout << a << ' ' << b << ' ' << c;
	    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char N[3];
  	int i,F = 1;
  
  	scanf("%s",N);
  
  	for(i = 0;N[i] !='\0';i++)
    {
    	if(N[i] == '7'){
    		printf("Yes\n");
          	F = 0;
          	break;
        }	
    }
  if(F)
    printf("No\n");
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main (void){
	int a,b,c,d;
	cin >> a >> b >> c >>d;
	int cost=min(a,b)+min(c,d);
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
struct P {
	long long place, time;
};
bool operator<(P a, P b) {
	return a.time < b.time;
}
bool operator>(P a, P b) {
	return a.time > b.time;
}
long long a[100000];
int main() {
	long long n, l;
	while (cin >> n >> l) {
		priority_queue<P, vector<P>, greater<P>>p;
		for (int i = 0; i < n; i++) {
			int howlong;
			cin >> howlong;
			a[i] = howlong;
		}
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				if (a[1] < a[0]) p.push(P{ i,l - a[0] });
			}
			else if (i == n - 1) {
				if (a[n - 1] > a[n - 2]) p.push(P{ i,l - a[n-1] });
			}
			else {
				if (a[i] > a[i - 1] && a[i] > a[i + 1]) p.push(P{ i,l - a[i] });
			}
		}
		long long sum = 0;
		while (!p.empty()) {
			P t = p.top(); p.pop();
			if (a[t.place] != 0) {
				a[t.place] = 0;
				sum = max(sum, t.time);
				long long i = t.place-1;
				if (i == 0) {
					if (a[1] < a[0]) p.push(P{ i,t.time+(l - a[0]) });
				}
				else if (i == n - 1) {
					if (a[n - 1] > a[n - 2]) p.push(P{ i,t.time+(l - a[n - 1]) });
				}
				else if(i>=0&&i<n){
					if (a[i] > a[i - 1] && a[i] > a[i + 1]) p.push(P{ i,t.time+(l - a[i]) });
				}
				i += 2;
				if (i == 0) {
					if (a[1] < a[0]) p.push(P{ i,t.time+(l - a[0] )});
				}
				else if (i == n - 1) {
					if (a[n - 1] > a[n - 2]) p.push(P{ i,t.time+(l - a[n - 1] )});
				}
				else if(i<n&&i>=0){
					if (a[i] > a[i - 1] && a[i] > a[i + 1]) p.push(P{ i,t.time+(l - a[i] )});
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 4660
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/

long long powmod(long long x, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n & 1) ret = ret * x % MOD;  // n の最下位bitが1ならば(nが奇数ならば) x^(2^i) をかける
		x = x * x % MOD;
		n >>= 1;  // n を1bit 左にずらす
	}
	return ret;
}



long long nCr_mod(long long n, long long r) {
	long long x = 1, y = 1;

	for (ll i = 0; i < r; i++) {
		x = x * (n - i) % MOD ;
		y = y * (i + 1) % MOD;
	}

	return x * powmod(y, MOD - 2) % MOD;
}



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll S;
	cin >> S;
	if (S <= 2) {cout << 0 << endl; return 0;}

	ll base = S / 3;
	ll ans = 0;


	FOR(i, 1, base) {

		ll last = S - 3 * i; //これを土台分だけ分配する

		ans += nCr_mod(last + i-1, i -1);
		ans %= MOD;

	}


	cout << ans << endl;




	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int N;
  const int M = 256;
  
  while(cin >> N && N){
    vector<int> L(N);
    REP(i, N) cin >> L[i];
    int bestS = 0, bestA = 0, bestC = 0;
    double best = 1e20;
    REP(S, 16)REP(A, 16)REP(C, 16){
      vector<int> R(N + 1);
      vector<int> O(N);
      R[0] = S;
      REP(i, N) R[i+1] = (A * R[i] + C) % M;

      
      map<int, int> count;
      REP(i, N) count[(L[i] + R[i+1]) % M]++;
      double h = 0;
      
      FOREACH(it, count){
        double p = (double)(it->second) / N;
        h -= p * log(p);
      }
      if(h < best - EPS){
        best =  h;
        bestS = S;
        bestA = A;
        bestC = C;
      }
    }
    cout << bestS << " " << bestA << " " << bestC << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

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

		rep(i,n)
		{
	   		double	pm,pe,pj;
			cin >> pm >> pe >> pj;


			if(pm >= 100 || pe >= 100 || pj >= 100)
			{
				cout << "A" << endl;
			}
			else
			{
				double temp = pm + pe;
				temp /= 2;

		   		double temp2 = pm + pe + pj;
				temp2 /= 3;

				if(temp >= 90)
				{
					cout << "A" << endl;
				}
				else if(temp2 >= 80)
				{
					cout << "A" << endl;
				}
				else if(temp2 >= 70)
				{
					cout << "B" << endl;
				}
				else if(temp2 >= 50 && (pm >= 80 || pe >= 80))
				{
					cout << "B" << endl;
				}
				else cout << "C" << endl;
			}	
		}
	}
}

Measured memory_bytes: 1224
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n2=n;
        int sum=0;
        List<Integer> list = new ArrayList<>();
        while (n > 0) {
            list.add(n % 10);
            n /= 10;
        }
        for(Integer it :list) {
            sum+=it;
        }
        if (n2%sum==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	char n[3];
	cin >> n[0] >> n[1] >> n[2];
	
	if(n[0]>=n[1] && n[0]>=n[2]){
		cout << n[0]<<n[0]<<n[0]<<endl;
	}else{
		n[0]++;
		cout << n[0]<<n[0]<<n[0]<<endl;
	}
	
	return 0;
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  
  if(a*n>=b){
    cout << b << endl;
  }else{
    cout << a*n << endl;
  }
}

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


def count1(A, B, i):
    # A〜Bにおけるi桁目の排他的論理和を求める
    under = 2**(i+1) - A % (2**(i+1))
    if under > 2**i:
        under = 0

    upper = max(0, B % (2**(i+1))-2**i+1)

    # print(i, under, upper)
    return (under+upper) % 2


ans = ((B+1)//2 - A//2) % 2  # 1桁目
for i in range(1, len(format(B, 'b'))):
    ans += count1(A, B, i)*2**i

print(ans)


Measured memory_bytes: 38384
from fractions import gcd
import sys
from collections import Counter

read = lambda: sys.stdin.readline().rstrip()

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 disjoint_set_of_common_divisors(A, B):

    return len(Counter(prime_factorize(gcd(A, B))).keys())+1

def main():
    
    A0, B0 = map(int, read().split())
    #A0 = tuple(map(int, read().split()))

    res = disjoint_set_of_common_divisors(A0, B0)

    print(res)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 5076
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    string S;
    S = to_string(N);
    for (int i=0; i<S.size(); i++) {
        if (S[i] == '9') {
            cout << '1';
        } else if (S[i] == '1') {
            cout << '9';
        } else {
            cout << S[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(input())
Rn = c.count("R") # 区切りの右側に存在するRの数
Wn = 0 # 区切りの左側に存在するWの数
ans = N
for i in range(N+1):
    if i == 0:
        ans = Rn
    else:
        if c[i-1] == "R":
            Rn -= 1
        else:
            Wn += 1
        ans = min(ans, min(Rn, Wn) + abs(Rn - Wn))
print(ans)

Measured memory_bytes: 10724
n = int(input())
array = list(map(int,input().split()))
dp = [0 for x in range(n)]
dp[1] = abs(array[1]-array[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(array[i-1]-array[i]),dp[i-2]+abs(array[i-2]-array[i]))
print(dp[-1])


Measured memory_bytes: 13928
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
class BIT{
    private:
        vector<ll> bit;
        ll size;
    public:
        BIT(ll n){
            bit.resize(n+1);
            size = n;
        }
        ll sum(ll i){
            ll res = 0;
            while(i > 0){
                res += bit[i];
                i -= i&-i;
            }
            return res;
        }
        void add(ll i,ll x){
            while(i <= size){
                bit[i] += x;
                i += i&-i;
            }
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    vector<ll> c(n);
    cins(all(c));
    ll l,r;
    vector<tri> p;
    rep(i,q){
        cin >> l >> r;
        l--;
        p.push_back(tri(r,l,i));
    }
    vector<ll> last(n,-1);
    rep(i,n){
        c[i]--;
        last[c[i]] = i;
    }
    BIT a(n);
    rep(i,n){
        if (last[i] != -1) a.add(last[i]+1,1);
    }
    SORT(p);
    ll nr = 0;
    vector<ll> ans(q);
    rep(i,q){
        ll ind;
        tie(r,l,ind) = p[i];
        while (nr < r){
            a.add(last[c[nr]]+1,-1);
            last[c[nr]] = nr;
            a.add(nr+1,1);
            nr++;
        }
        ans[ind] = a.sum(r)-a.sum(l);
    }
    rep(i,q){
        PRINT(ans[i]);
    }
}


Measured memory_bytes: 31100
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int a,b;
    int ans;
    cin >> a >> b;
    if(a<=b){
        ans=a;
    }else{
        ans=a-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;


int main(){
  ll MOD = 1000000007;
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> modest(N);
  rep(i,N){
    cin >> A.at(i);
    if(i>0){
      modest.at(i) = modest.at(i-1) + A.at(i);
      modest.at(i) %= MOD;
    }
    else{
      modest.at(i) = A.at(i);
    }
  }
  ll ans = 0;
  rep(i,N-1){
    ll wa = modest.at(N-1)-modest.at(i);
    wa=(wa+MOD)%MOD;
    ans += wa*A.at(i);
    ans %= MOD;
  }
  cout << ans << endl;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool ok = false;
    for (auto g : G[0]) {
        if (g == N - 1) ok = true;
        for (auto n : G[g]) {
            if (n == N - 1) ok = true;
        }
    }

    if (ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12016
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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 ll INF=1e9+1;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
    return 0;
} 

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  ll h;
  cin >> h;
  
  ll res=1,cnt=0;
  while(h>0) h/=2,cnt++;
  rep(i,0,cnt) res*=2;
  
  cout << res-1 << endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
	int n;
	std::cin >> n;

	int i = 1;

	while(++i <= n)
	{
		int x = i;
		if ( x % 3 == 0 )
			std::cout << " " << i;
		else
		{
			do {
				if ( x % 10 == 3 )
				{
					std::cout << " " << i;
					x = 0;
				}
				x /= 10;
			} while(x);
		}
	}
	std::cout << std::endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int N; cin >> N;
  ll a[N]; rep(i,N) cin >> a[i];
  ll x = 0; rep(i,N) x ^= a[i];
  ll result = 0;
  per(i,30) {
    // cout << i << ":" << x << "->" << result << endl;
    bool ok = false;
    if (i==0&&x&1) {
      rep(j,N) if (a[j]&1) { ok = true; result++; break; }
      if (!ok) { cout << -1 << endl; return 0; }
    }
    else if (x&(1<<i)) {
      rep(j,N) if (a[j]%(1<<i+1)==(1<<i)) { ok = true; x ^= (1<<i+1)-1; result++; break; }
      if (!ok) { cout << -1 << endl; return 0; }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int main() {
	int a, b;
	cin >> a >> b;
	if (b == 100)b++;
	cout << b;
	REP(i, a)cout << "00";
	cout << endl;
	return 0;
}

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

ans = 0
x = -1
for i in range(N):
    if x == (A[i]-1):
        x = A[i]
        ans += (B[x-1] + C[x-2])
    else:
        x = A[i]
        ans += B[x-1]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	int d[2][1001]={0},a,b,i=0;
	char c;
	while(!cin.eof())
		if(isdigit(cin.get())){
			cin.unget();
			cin>>a>>c>>b;
			d[i][a]++;
		}
		else c==0?i++:c=0;
	for(i=0;i<1001;i++){
		a=d[0][i];
		b=d[1][i];
		if(a&&b)cout<<i<<" "<<a+b<<"\n";
	}
}

Measured memory_bytes: 1168
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[222];
int main()
{
	geti(n);
	for(int i=1;i<=2*n;i++)geti(a[i]);
	sort(a+1,a+2*n+1);
	ll ans=0;
	for(int i=1;i<=n;i++)ans+=a[i*2-1];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

string ss[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

    int  b = -1;
    for(int i = 0; i < 14; i++){
        if(ss[i] == s){
            b = i;
            break;
        }
    }

    for(int i = b + 1; i < 14; i++){
        if(ss[i] == "SUN")
            return cout << i - b << '\n', 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str;
	cin>>str;
	int sum=0;
	for(char x:str)
	{
		sum+=(x-48);
	}
	if(sum%9==0)
	{
        cout<<"Yes"<<endl;
	}
	else
	   cout<<"No"<<endl;
}


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

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

	int n;
	cin >> n;

	vector<int> tab(n);
	for(int i = 0; i<n; i++)
		cin >> tab[i];

	sort(tab.begin(), tab.end());
	cout << tab[n/2] - tab[n/2-1] << '\n';
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static int[][] l;
	public static int[] d;
	public static void main(String[] args) throws NumberFormatException, IOException {
		// input & init
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		l = new int[n+1][n+2];
		for(int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			int u = Integer.parseInt(str[0]);
			for(int j = 1; j < str.length; j++){
				l[u][j-1] = Integer.parseInt(str[j]);
			}
		}

		d = new int[n+1];
		for(int i = 1; i <= n; i++){
			d[i] = -1;
		}
		
		// search
		int[] q = new int[n*n]; //queue
		int ps = 0; // start pointer
		int pe = 1; // end pointer
		q[0] = 1; // enqueue id 1
		
		while(ps != pe){
			// dequeue
			int id = q[ps];
			ps += 1;
			if(d[id] == -1){
				d[id] += 1;
			}

			// enqueue the adjacent nodes
			for(int i = 1; i <= l[id][0]; ++i){
				if(d[l[id][i]] == -1){
					q[pe] = l[id][i];
					pe += 1;
					d[l[id][i]] = d[id] + 1;
				}
			}
		}
		
		// print
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i <= n; i++){
			sb.append(i + " " + d[i] + "\n");
		}
		System.out.print(sb);
	
	}
	
}

Measured memory_bytes: 24500
import java.io.*;
import java.util.*;
public class Main{

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		long x=Integer.valueOf(cmd[0]);
		long ans1=0;
		long ans2=0;
		for(long i=-1000;i<=1000;i++)
		{
			long a=(long)Math.pow(i, 5);
			for(long j=-1000;j<=1000;j++)
			{
				long b=(long)Math.pow(j, 5);
				if(a-b==x)
				{
					ans1=i;
					ans2=j;
					break;
				}
			}
		}
		System.out.println(ans1+" "+ans2);
	}

}


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

using namespace std ;

long long a , b [ 200001 ] , cnt , ans , m ;

int main ()
{
    cin >> a >> m ;
    for ( int i = 1 ; i <= a ; ++ i ){
        cin >> b [ i ] ;
    }
    for ( int i = 1 ; i <= a ; ++ i ){
        cnt = b [ i ] + b [ i + 1 ] ;
        if ( cnt > m ){
            ans += cnt - m ;
            b [ i + 1 ] = m - b [ i ] ;
        }
        /*
        long long x = m * 2 ;
        if ( cnt [ i ] - x + 1 >= 0 ){
            ans += cnt [ i ] - x + 1 ;
        }
        */
    }
        cout << ans ;
}


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

class Solve {
private:
	using vb = std::vector<bool>;
	using vvb = std::vector<vb>;

	int h, w;
	vvb map;

	void dfs(int r, int c)
	{
		if (!map[r][c]) return;
		map[r][c] = false;
		for (int i{r - 1}; i <= r + 1; i++)
			for (int j{c - 1}; j <= c + 1; j++)
				dfs(i, j);
	}

public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d%d", &w, &h);
		if (w == 0)
		{
			is_last_query = true;
			return;
		}
		map.resize(h + 2, vb(w + 2));
		for (int i{1}; i <= h; i++)
			for (int j{1}; j <= w; j++)
			{
				int c;
				scanf("%d", &c);
				map[i][j] = c == 1;
			}

		int count{};
		for (int i{1}; i <= h; i++)
			for (int j{1}; j <= w; j++)
			{
				if (!map[i][j]) continue;
				count++;
				dfs(i, j);
			}

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

int main()
{
	while (!Solve().is_last_query);

	return 0;
}



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

typedef long long ll;

int main(void){
    ll n, z, w;
    cin >> n >> z >> w;
    vector<ll> v(n+1);
    v.at(0) = w;
    for(int i=1; i<=n; i++){
        cin >> v.at(i);
    }

    ll dp[2][n];
    dp[0][n-1] = abs(v.at(n) - v.at(n-1));
    dp[1][n-1] = dp[0][n-1];

    ll minx = dp[0][n-1], maxy = dp[1][n-1];

    for(int i=n-2; i>=0; i--){
        dp[0][i] = max(maxy, abs(v.at(n) - v.at(i)));
        dp[1][i] = min(minx, abs(v.at(n) - v.at(i)));
        minx = min(minx, dp[0][i]);
        maxy = max(maxy, dp[1][i]);
    }

    cout << dp[0][0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//---------------------------------------------
// Mr.HITMAN/hblord787
// Solution for Problem Code : A - Serval vs Monster
// Contest : Beginner 153 
//-------------------------------------------- 
int main() {
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////    
	ios_base::sync_with_stdio(false); // fast io
	cin.tie(NULL);
	cout.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    int n,k;
    cin >> n >> k;
  	
  	if(k >= n)
    {
    cout << 1;
    }
  	else{
    	if( n % k == 0)
        {
        cout << (n/k);
        }
      	else {
        	cout << ((n/k) + 1);
        }
    }
	
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod int = 1e9 + 7

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}

	ans := 0
	x := 0
	for i := 0; i < n; i++ {
		ans += (as[i] * x) % mod
		ans %= mod
		x = (x + as[i]) % mod
	}
	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 6128
/* ex4_1
   offNaria */
#include <stdio.h>

int main(void){
  int number, range;
  scanf("%d %d", &number, &range); //監視員は2*range+1本の木を監視できる
  if(number % (2 * range + 1) == 0){
    printf("%d\n", number / (2 * range + 1));
  }else{
    printf("%d\n", number / (2 * range + 1) + 1);
  }
  return 0;
}


Measured memory_bytes: 128
import numpy as np

N, X = map(int, input().split())
L = list(map(int, input().split()))
# D = [np.array([])]
D = [0, 0]

for i in range(2, N + 2):
    D.append(D[i - 1] + L[i - 2])

D2 = np.array(D)    # numpy配列を作成

D3 = D2[D2 <= X]    # numpyを使ってX以下の要素を抽出

print('{}'.format(D3.size - 1))    # 回数を出力(D3[0]は不要なのでｰ1)



Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vector<pair<int,int>> p(n);
  rep(i,n){
    p.at(i).second=i;
    cin>>p.at(i).first;
  }
  sort(all(p));
  rep(i,n){
    cout<<p.at(i).second+1<<' ';
  }
  cout<<endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    ll n,m;
    ll a[maxn];
    map<ll,ll> ex;
    ull sum=0;
    ll ans=0;
    
    cin >>n >>m;
    
    rep(i,n){
        cin >> a[i];
    }
    
        
    rep(i,n){
        sum+=a[i];
        if(sum%m==0)ans++;
        ans+=ex[sum%m];
        ex[sum%m]++;
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m;
    cin >> n >> m;
    print(min(m / 2, (n * 2 + m) / 4));

}




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

int main(){
  int A, B, N, i, j, tot, result = 0;
  cin >> N >> A >> B;
  
  for (i = 1; i <= N; i++){
    j = i;
    while(j > 0){
      tot += j%10;
      j /= 10;
    }
    if(tot >= A && tot <= B){
      result += i;
    }
    tot = 0;
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int N, A;
    static int[] x;
    static long[][][] dp;

    static long dfs(int idx, int sum, int cnt) {
        if (dp[idx][sum][cnt] != -1) {
            return dp[idx][sum][cnt];
        }
        if (idx == N) {
            if (cnt > 0 && sum % cnt == 0 && sum / cnt == A) {
                return 1;
            }
            return 0;
        }
        long res = 0;
        res += dfs(idx + 1, sum, cnt);
        res += dfs(idx + 1, sum + x[idx], cnt + 1);
        return dp[idx][sum][cnt] = res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            N = sc.nextInt();
            A = sc.nextInt();
            x = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = sc.nextInt();
            }
            dp = new long[N + 1][N * 50 + 1][N + 1];
            for (int i = 0; i < N + 1; i++) {
                for (int j = 0; j < N * 50 + 1; j++) {
                    for (int k = 0; k < N + 1; k++) {
                        dp[i][j][k] = -1;
                    }
                }
            }
            System.out.println(dfs(0, 0, 0));
        }
    }
}


Measured memory_bytes: 86868
// ModSum
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;
typedef long long LL;
int main()
{
    LL N;
    cin >> N;
    cout << (LL) (N * (N -1)) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if( 0 <= (x - r) && (x + r) <= W && 0 <= (y - r)  && (y + r) <= H )
    {cout << "Yes" << endl;
    }else
    {cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
H = list(map(int,input().split()))
maxh = 0
#minh = 10**9
max_drawdown = 0
ans = "Yes"
for i in H:
    max_drawdown = min(max_drawdown,i-maxh)
    maxh = max(maxh,i)
if max_drawdown <= -2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
int n;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cout << "ACL";
	}
	cout << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n ;
    cin >> n;
    set<string>s;
    string z;
    for(int i = 0 ; i < n ; i++)
    {
        cin >>z;
        s.insert(z);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 19288
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int K =sc.nextInt();
      int X =sc.nextInt();     
      
      if(K*500>=X){
      System.out.println("Yes");
      }
      else{
      System.out.println("No");
      }
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	ll n,a,b[200005],sum=0;
	for(int i=0;i<200005;i++)b[i]=0;
	vector<ll>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		b[a]++;
	}
	for(int i=1;i<=n;i++)sum+=b[i]*(b[i]-1)/2;

	ll c,ans;
	for(int i=0;i<n;i++)
	{
		c=sum-(b[v[i]]*(b[v[i]]-1)/2);
		ans=c+((b[v[i]]-1)*(b[v[i]]-2)/2);
		cout<<ans<<endl;
		c=0;
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 5872
#include<stdio.h>
int N, n, i, t;
int A[100001];
char B[100001];
int main(){
	scanf("%d", &N);
	for(i=1; i<=N; i++){
		scanf("%d", A+i);
	}
	i=0;
	n=1;
	do{
		B[n] = 1;
		n = A[n];
		i++;
	}while(!B[n] && n!=2);
	if(n==2){
		printf("%d\n", i);
	}else{
		printf("-1\n");
	}
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0) break;
			String str = sc.next();
			StringBuilder s = new StringBuilder(str);
			
			for(int i=0;i<n;i++) {
				int num = -1;
				int cnt = 0;
				StringBuilder next = new StringBuilder();
				debug(s, s.length());
				for(int j=0;j<s.length();j++) {
					debug(s.charAt(j)-'0', num, cnt);
					if( num != s.charAt(j) - '0' ) {
						if ( num != -1 ) {
							next.append(cnt);
							next.append(num);
						}
						num = s.charAt(j) - '0';
						cnt = 1;
					}
					else {
						cnt++;
					}
				}
				next.append(cnt);
				next.append(num);
				debug(next);
				s = new StringBuilder(next);
			}
			System.out.println(s);
		}
	}

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

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2)
    {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

void cut_cake(map<int, pair<int, int>> &piece_map, int id, int s, int cut_num) {
    int w1 = piece_map.at(id).first;
    int d1 = piece_map.at(id).second;
    s %= w1 + d1;
    int w2, d2, w3, d3;
    if (s < w1) {
        w2 = min(s, w1 - s);
        w3 = max(s, w1 - s);
        d2 = d3 = d1;
    } else {
        d2 = min(s - w1, w1 + d1 - s);
        d3 = max(s - w1, w1 + d1 - s);
        w2 = w3 = w1;
    }
    piece_map[2 * cut_num - 1] = {w2, d2};
    piece_map[2 * cut_num] = {w3, d3};
}

void update(vector<int> &id_vec, int p, int cut_num) {
    id_vec.erase(id_vec.begin() + p);
    id_vec.push_back(2 * cut_num - 1);
    id_vec.push_back(2 * cut_num);
}

vector<int> calc_area(const vector<int> &id_vec,
                const map<int, pair<int, int>> &piece_map) {
    int num_piece = id_vec.size();
    vector<int> area_vec(num_piece);
    for (int i = 0; i < num_piece; ++i) {
        int id = id_vec.at(i);
        int area = piece_map.at(id).first * piece_map.at(id).second;
        area_vec.at(i) = area;
    }
    return area_vec;
}

int main() {
   vector<int> id_vec;
   map<int, pair<int, int>> piece_map;
   int n, w, d;
   while (cin >> n >> w >> d) {
       if (n == 0 && w == 0 && d == 0) break;
       id_vec.clear();
       piece_map.clear();
       id_vec.push_back(0);
       piece_map[0] = {w, d};
       for (int i = 0; i < n; ++i) {
           int p, s;
           cin >> p >> s;
           --p;
           cut_cake(piece_map, id_vec.at(p), s, i + 1);
           update(id_vec, p, i + 1);
       }
       vector<int> area_vec = calc_area(id_vec, piece_map);
       sort(area_vec.begin(), area_vec.end());
       for (int i = 0; i < n; ++i) 
           cout << area_vec.at(i) << " ";
       cout << area_vec.at(n) << endl;
   }
}



Measured memory_bytes: 3156
#include<stdio.h>
int main(void){
  int i,j,k,l,a,b,c,d=0,n=0;
  int number[2000000];
  scanf("%d",&n);
  char order[12];

  for(i=0;i<n;i++){
    scanf("%s %d",order,&b);
    if(order[0]=='i'){
      number[i]=b;
    }else if(order[6]=='F'){
      i-=2;
      n-=2;
    }else if(order[6]=='L'){
      i--;
      n--;
      d++;
    }else{
      i--;
      n--;
      l=0;
    
    for(j=i;j>=0;j--){
      if(l>0)break;
      if(b==number[j]){
	k=i-j;
	a=0;
	l++;
	while(k!=a++){
	  number[j+a-l]=number[j+a];
	}
	i--;
	n--;
      }
    }
  }
  }
  for(i=0;i<n-d;i++){
    if(i==n-d-1){
      printf("%d\n",number[n-1-i]);
    }else{
      printf("%d ",number[n-1-i]);
    }
  }
  return 0;
}



Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    cout << setprecision(10) << (d == 0 ? 1 : 2) * (m - 1) * (n - d) / (n * n) << endl;
    return 0;
}

Measured memory_bytes: 256