akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Numerics;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int Mod = (int)Math.Pow(10, 9) + 7;
            BigInteger ans = 0;
            ans += BigInteger.ModPow(10, n, Mod);
            ans -= (BigInteger.ModPow(9, n, Mod)*2)%Mod;
            ans += BigInteger.ModPow(8, n, Mod);
            if (ans < 0) ans += Mod;
            Console.WriteLine(ans % Mod);

        }
    }
}


Measured memory_bytes: 28004
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
#define F(i,x,y) for (int i=x; i<=y; i++)
#define D(i,x,y) for (int i=x; i>=y; i--)
using namespace std;
const int N=3333;
ll f[N];
int a[N];
int n,k;
ll p=998244353;
int main(){
	scanf("%d%d",&n,&k);
	F(i,1,n) scanf("%d",&a[i]);
	ll ans=0;
	F(i,1,n){
		f[0]=i;
		D(j,k,a[i]) f[j]=(f[j]+f[j-a[i]])%p;
		ans=(ans+f[k])%p;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, t;
	long double ans, d, a, b, c, xx, yy, r, cx, cy, dx, dy, dr;
	cin >> n;
	vector<long double> x(n), y(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	//ans = 0;
	//for (i = 0; i < n; i++) {
	//	for (j = i + 1; j < n; j++) {
	//		d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
	//		ans = max(ans, d);
	//	}
	//}

	a = 0; b = 10000;
	while (a + 0.00000000001 < b) {
		c = (a + b) / 2;

		bool solved = false;
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				// find two points of center with distance of c to both points
				d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
				if (d > 2 * c) continue;	// too far apart

				// mid point
				cx = (x[i] + x[j]) / 2;
				cy = (y[i] + y[j]) / 2;

				dx = (x[i] - x[j]);
				dy = (y[i] - y[j]);
				dr = d;

				d /= 2;
				r = sqrt(c * c - d * d);

				for (t = 0; t < 2; t++) {
					if (t == 0) {
						xx = cx + r / dr * dy; 
						yy = cy - r / dr * dx;
					}
					else {
						xx = cx - r / dr * dy;
						yy = cy + r / dr * dx;
					}

					bool ok = true;
					for (k = 0; k < n; k++) {
						d = sqrt((x[k] - xx) * (x[k] - xx) + (y[k] - yy) * (y[k] - yy));
						if (d > c + 0.000000001)
							ok = false;
					}
					if (ok) {
						solved = true;
						goto outer;
					}
				}
			}
		}
	outer:;
		if (solved) b = c;
		else a = c;
	}

	ans = a;


	cout << setprecision(10) << fixed << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int sum[100010];
map<int, int> mp;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[100010];
    rep(i, N) cin >> A[i];
    rep(i, N) sum[i + 1] = (sum[i] + A[i]) % M;
    rep(i, N + 1) mp[sum[i]]++;
    int ans = 0;
    rep(i, N) {
        mp[sum[i]]--;
        ans += mp[sum[i]];
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int a, b, c;
	a = n - w + 1;
	b = n - h + 1;
	cout << a * b << endl;
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

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

    par = [a[-1]]
    rest = a[:-1]

    for _ in [0]*n:
        next_par = []
        next_rest = []

        for e in par:
            while True:
                if len(rest) == 0:
                    print('No')
                    exit()
                k = rest.pop()
                if k < e:
                    next_par.append(k)
                    break
                else:
                    next_rest.append(k)
        
        par += next_par
        par.sort(reverse = True)
        rest += next_rest[::-1]
    
    print('Yes')

if __name__ =='__main__':
    main()

Measured memory_bytes: 134184
#include<bits/stdc++.h>
#define forn(i,a,b) for(long long i=a;i<=b;i++)
#define fork(i,a,b,k) for(long long i=a;i<=b;i+=k)
using namespace std;
typedef long long ll;
const ll M=1000000007;
char a[1005][1005];
int h,w,dp[1005][1005];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>w;
	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			cin>>a[i][j];
		}
	}
	for(int i=0; i<=w+1; i++) {
		dp[0][i]=0;
		dp[h+1][i]=0;
	}
	for(int i=0; i<=h+1; i++) {
		dp[i][0]=0;
		dp[i][w+1]=0;
	}
	dp[1][1]=1;
	for(int j=2; j<=w; j++) {
		if(a[1][j]=='#')dp[1][j]=0;
		else dp[1][j]=(dp[0][j]+dp[1][j-1])%M;
	}
	for(int i=2; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			if(a[i][j]=='#')dp[i][j]=0;
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 5248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();


        int N;
        void solve() {
            N = cin.nextInt();

            long ans=0;

            for (int i = 1; i <= N; i++)
                ans += i;

            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }
        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;}
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int

#define int long long

using namespace std;

signed main(){
    int N; cin>>N;
    vector <int> a1;
    a1.resize(N);
    vector <int> a2=a1;
    vector <int> a3 = a1;
    for(int i=0;i<N;i++) cin>>a1[i];
    for(int i=0;i<N;i++) cin>>a2[i];
    for(int i=0;i<N;i++) cin>>a3[i];

    vector <int> fmax(N+1,0);
    vector <int> lmin(N+1,0);
    vector <int> ans(N+1,0);

    priority_queue <int, vector<int>, greater<int>> pf;
    int fsum = 0;

    for(int i=0;i<N;i++){
        pf.push(a1[i]);
        fsum += a1[i];
    }
    fmax[0] = fsum;

    for(int i=1;i<=N;i++){
        int origin = pf.top();
        if(a2[i-1] < origin) {fmax[i] = fsum;continue;}
        else {fsum = fsum - origin + a2[i-1];pf.pop();pf.push(a2[i-1]);fmax[i] = fsum;}
    }
    fsum = -INF;
    //##################


    priority_queue <int> pl;
    int lsum = 0;

    for(int i=0;i<N;i++){
        pl.push(a3[i]);
        lsum += a3[i];
        //cout<<lsum<<endl;
    }
    lmin[N] = lsum;

    for(int i=N-1;i>=0;i--){
        int origin = pl.top();
        //cout<<origin<<endl;
        if(a2[i] > origin) {lmin[i] = lsum;continue;}
        else {lsum = lsum - origin + a2[i];pl.pop();pl.push(a2[i]);lmin[i] = lsum;}
        //cout<<i<<" "<<lsum<<endl;
    }
    for(int i=0;i<=N;i++){
        ans[i] = fmax[i] - lmin[i];
    }

    int output = -INF * 100000;
    for(int i=0;i<=N;i++){
        output = max(output,ans[i]);
       // cout<<i<<" "<<fmax[i]<<" "<<lmin[i]<<endl;
    }
cout<<output<<endl;

    return 0;
}

Measured memory_bytes: 7284
import java.util.*;


class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int now = 0;
        int count = 1;
        for(int i=0;i<N;i++){
            now = now + sc.nextInt();
            if(now <= X)count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    int A, B;
    cin >> A >> B;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i < B && j < A) cout << 1;
            else if(i >= B && j < A) cout << 0;
            else if(i < B && j >= A) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        for (int x = 1; x <= 3500; x++) {
            for (int y = 1; y <= 3500; y++) {
                if (4 * x * y > N * x + N * y && (N * x * y) % (N * x + N * y - 4 * x * y) == 0) {
                    int z = -(N * x * y) / (N * x + N * y - 4 * x * y);
                    out << x << ' ' << y << ' ' << z << '\n';
                    return;
                }
            }
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int t,h=0,m=0;
    scanf("%d",&t);
    while(t>=3600){
        t=t-3600;
        h++;
    }
    while(t>=60){
        t=t-60;
        m++;
    }
    printf("%d:%d:%d\n",h,m,t);
    return 0;
}

Measured memory_bytes: 592
N, Q = map(int, input().split())
S = input()
ac = [0 for i in range(N)]
s = [0 for i in range(N+1)]
for i in range(N-1):
    if S[i:i+2] == 'AC':
        ac[i] = 1

for i in range(N):
    s[i+1] = s[i] + ac[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(s[r-1]-s[l-1])

Measured memory_bytes: 8540
a='abcdefghijklmnopqrstuvwxyz'
while 1:
    try:s=input()
    except:break
    for i in range(1,27):
        b=''
        for x in s:
            b+=a[a.index(x)-i]if x in a else x
        if 'the' in b or 'this' in b or 'that' in b:print(b);break

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define Endl endl
#define INF 99999999


int main(){

        int n,z,w;
        int a[2000+10];

        cin >> n >>z >>w;

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

        if(n ==1)cout << abs(a[0] - w);
        else cout << max(abs(a[n-1]-w), abs(a[n-1] - a[n-2]));
        return 0;

}


Measured memory_bytes: 256
p = list(input())
t  = list(input())
count = 0
w =[]
a = len(t)
b = len(p)

for i in range(b-a+1):
    count = 0
    for s in range(a):
        if p[i] != t[s]:
            count +=1
        i +=1
    w.append(count)
print(min(w))

Measured memory_bytes: 9072
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
 
 
// Write From This Line
const int mod = 1e9+7;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for(ll i = k; i <= n+1 ; i ++){
		ll left, right; // left:= 小さい方からi 個，right:= 大きい方からi個
		left = (i * (i - 1)) / 2;
		right = (i * (n+1 + n-i) )/ 2;
		ans += (right - left) % mod  + 1;
		ans %= mod;
	}
	cout << ans << endl;
}

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

int main() {

string str1, str2;
cin >> str1 >> str2;

bool flag = true;

if (str1.size()+1 == str2.size()){
    for (int i = 0;i < str1.size(); i++){
        if(str1.at(i) != str2.at(i)) flag = false;
    }
    if(flag == true) cout << "Yes" << endl;
    else cout << "No" <<endl;
}
else  cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

typedef struct D
{
	int n,r,l,d,p,dep,h,sub,deg;
}D;

D node[30];
int i,j,N,r,l,n;

int dfs(int p,int d)
{
	int a,b;
	if(p==-1)return -1;
	node[p].dep=d;
	a=dfs(node[p].r,d+1);
	b=dfs(node[p].l,d+1);
	if(a==-1&&b==-1)
		node[p].h=0;
	else
		node[p].h=(a>b?a:b)+1;
	return node[p].h;
}

int main()
{
	memset(node,-1,sizeof(node));
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&n,&l,&r);
		node[n].l=l;
		node[n].r=r;
		node[n].deg=(r!=-1)+(l!=-1);
		node[l].sub=r;
		node[r].sub=l;
		if(l!=-1)node[l].p=n;
		if(r!=-1)node[r].p=n;
	}
	for(i=0;i<N;i++)
		if(node[i].p==-1)
			dfs(i,0);

	for(i=0;i<N;i++)
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
		i,node[i].p,node[i].sub,node[i].deg,node[i].dep,node[i].h,node[i].p==-1?"root":node[i].l==-1&&node[i].r==-1?"leaf":"internal node");
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int z=s-i-j;
      if(z>=0&&z<=k){
        ans++;
      
      }
    }
  }
      cout<<ans<<endl;
      }
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  int j=0,k=0;
  for(int i=0;i<2*n;i++)
  {
      if(i%2)
        cout<<b[k++];
      else
        cout<<a[j++];
  }
}

Measured memory_bytes: 256
import math
N, M  = list(map(int, input().split()))

s = M // N
r_list = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0 and i <= s:
        if M // i <= s:
            r_list.append(M // i)
        else:
            r_list.append(i)
r_list.sort()
r_list.reverse()
print(r_list[0])

Measured memory_bytes: 3060
import java.util.*;

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

        int n = sc.nextInt();

        int[] a = new int[n];
        int xor = 0;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            xor ^= a[i];
        }

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(a[i] ^ xor).append("\n");
        }

        System.out.println(sb);

    }
}


Measured memory_bytes: 61256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
char a[55][55],b[55][55];
int main()
{
    int n,m;
    bool ju=false;
    scanf("%d%d",&n,&m);
    //getchar();
    for(int i=0;i<n;++i)
        scanf("%s",a[i]);
    for(int i=0;i<m;++i)
        scanf("%s",b[i]);
    int k=n-m;
    for(int i=0;i<=k;++i)
    {
        if(ju) break;
        for(int j=0;j<=k;++j)
        {
            bool juu=true;
            for(int x=0;x<m;++x)
                for(int y=0;y<m;++y)
            {
                if(a[i+x][j+y]!=b[x][y])
                {
                    juu=false;
                    break;
                }
            }
            if(juu)
            {
                ju=true;
                break;
            }
        }
    }
    if(ju) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

int main() {
  int N; cin >>N;
  int ans=0;
  rep_eq(i,1,N) {
    ans+=i;
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3640
a,b = map(int,input().split())
s = input()
l = [str(i) for i in range(10)]
for i in range(a):
    if not s[i] in l:
        print('No')
        exit()
for i in range(b):
    if not s[a+i+1] in l:
        print('No')
        exit()
if not s[a]=='-':
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

const int MAXN = 1e5 + 10;
bool dp[MAXN];
int b[MAXN];

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

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

    for (int i = 0; i <= k; i++) {
        bool a[n];
        for (int j = 0; j < n; j++) {
            if (i - b[j] < 0 || dp[i - b[j]])
                a[j] = 1;
            else
                a[j] = 0;
        }

        bool ans = a[0];
        for (int j = 1; j < n; j++)
            ans = (ans && a[j]);

        dp[i] = !ans;
    }

    if (dp[k])
        cout << "First";
    else
        cout << "Second";

    return 0;
}


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

int main(void)
{
    // input
    int n, m, x;
    cin >> n >> m >> x;
    int a[12][12];
    vector<int> cost(n);
    rep (i, n) {
        cin >> cost[i];
        rep (j, m) cin >> a[i][j];
    }

    // compute
    vector<int> skill(m);
    int flag;
    int minNm = 10000000;
    int total;
    rep(s, 1<<n) {
        flag = 1;
        total = 0;
        rep(i, m) skill[i] = 0;
        rep(i, n) {
            if(s>>i&1) {
                rep(j, m) skill[j] += a[i][j];
                total += cost[i];
            }
        }
        rep(i, m) if (skill[i] < x) flag = 0;
        if (flag == 1) minNm = min(minNm, total);
    }
    if (minNm == 10000000) cout << -1 << endl;
    else cout << minNm << endl;

}

Measured memory_bytes: 3556
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::{max, min};
use im_rc::HashMap;

#[fastout]
fn main() {
    input! {
    n: usize,
    }
    let mut map = vec![vec![0; 10]; 10];
    for i in 1..=n {
        let (t, b) = tb(i);
        map[t][b] += 1;
    }
    let mut ans = 0;
    for i in 1..=n {
        let (t, b) = tb(i);
        ans += map[b][t];
    }
    println!("{}", ans);
}


fn tb(n: usize) -> (usize, usize) {
    let mut n = n;
    let b = n % 10;
    let mut t = 0;
    while n > 0 {
        t = n;
        n /= 10;
    }
    (t, b)
}

Measured memory_bytes: 2108
n=int(input())
a=list(map(int,input().split()))
mn=10**18
ng=0
sm=0
for i in a:
  sm+=abs(i)
  mn=min(mn,abs(i))
  if i<0:
    ng+=1
if ng%2==0:
  print(sm)
else:
  print(sm-mn*2)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, count=0, ans;
 	cin >> n;

 	for(int i=0;i<n;i++){
 		int a;
 		count = 0;
 		cin >> a;
 		while(a%2==0 && a>0){
 			a /= 2;
 			count++;
 		}
 		if(i==0) ans=count;
 		if(count<ans) ans=count;
 	}
 	cout << ans << endl;
}

Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift()
A = line.split(' ')[0] * 1
B = line.split(' ')[1] * 1
ans = (A + B) / 2 == ~~((A + B) / 2) ? (A + B) / 2 : 'IMPOSSIBLE'  
console.log(ans)

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define S 10
using namespace std;

int main(){
    int arr[S];

    for(int i=0;i<S;i++)
        cin>>arr[i];
    sort(arr,arr+S);
    //cout<<endl;
    for(int i=S-1;i>=S-3;i--)
        cout<<arr[i]<<endl;

return 0;
}

Measured memory_bytes: 1176
# coding: utf-8

x = list(map(int, input().split()))
lenx = len(x)
for i in range(lenx):
    j = lenx - 2
    while i <= j:
        if x[j] > x[j + 1]:
            temp = x[j]
            x[j] = x[j + 1]
            x[j + 1] = temp
        j -= 1
for i in range(lenx):
    print(x[i], end = '')
    if i < lenx - 1:
        print(' ', end = '')
print('')


Measured memory_bytes: 5600
n = int(input())
a_lst = input().split()
odd = [a for i, a in enumerate(a_lst) if i % 2 != 0]
even = [a for i, a in enumerate(a_lst) if i % 2 == 0]

if n % 2 == 0:
  b = list(reversed(odd)) + even
else:
  b = list(reversed(even)) + odd
print(' '.join(b))

Measured memory_bytes: 30944
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m;
  cin >> n >> m;
  int k[m];
  vector< vector< int > > s(m);
  for(int i = 0; i < m; i++){
    cin >> k[i];
    for(int j = 0; j < k[i]; j++){
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  int p[m];
  for(int i = 0; i < m; i++) cin >> p[i];

  int count = 0;
  for(int t = 0; t < (1 << n); t++){
    bool all_on = true;
    for(int i = 0; i < m; i++){
      int c = 0;
      for(int j = 0; j < k[i]; j++){
        if((t & (1 << (s[i][j] - 1))) != 0) ++c;
      }
      if((c % 2) != p[i]){
        all_on = false;
        break;
      }
    }
    if(all_on) ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <math.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

ll max(ll a, ll b)
{
  if (a > b)
  {
    return a;
  }
  return b;
}

int main()
{
  static const double pi = 3.141592653589793;
  double a,b;
  cin >> a >> b;
  double h,m;
  cin >> h >> m;
  double sita = fabs(60.0*h-11.0*m);
  sita /= 2.0;
  if(360-sita < sita)
  {
    sita = 360.0-sita;
  }
  sita = 180.0/sita;
  // cout << sita << endl;
  double z = pow(a,2)+pow(b,2) - 2*a*b*cos(pi/sita);
  double ans = pow(z,0.5);
  cout << std::fixed << std::setprecision(20) << ans << endl;
}


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

struct Rectangle{
    int height,pos;
};

int h,w;
vector<vector<int>> T(1401,vector<int>(1401));
vector<vector<int>> buffer(1401,vector<int>(1401));

int getLargestRectangle(int size,vector<int> &buffer){
    stack<Rectangle> s;
    int maxv=0;
    buffer[size]=0;
    for(int i=0;i<=size;i++){
        Rectangle rect;
        rect.height=buffer[i];
        rect.pos=i;
        if(s.empty()){
            s.push(rect);
        }
        else{
            if(s.top().height<rect.height){
                s.push(rect);
            }
            else if(s.top().height>rect.height){
                int target=i;
                while(!s.empty()&&s.top().height>=rect.height){
                    Rectangle pre=s.top();
                    s.pop();
                    int area=pre.height*(i-pre.pos);
                    maxv=max(maxv,area);
                    target=pre.pos;
                }
                rect.pos=target;
                s.push(rect);
            }
        }
    }
    return maxv;
}

int getLargestRectangle(){
    for(int j=0;j<w;j++){
        for(int i=0;i<h;i++){
            if(buffer[i][j]){
                T[i][j]=0;
            }
            else{
                if(i==0){
                    T[i][j]=1;
                }
                else{
                    T[i][j]=T[i-1][j]+1;
                }
            }
        }
    }
    int maxv=0;
    for(int i=0;i<h;i++){
        maxv=max(maxv,getLargestRectangle(w,T[i]));
    }
    return maxv;
}

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>buffer[i][j];
        }
    }

    cout<<getLargestRectangle()<<endl;
}


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

using namespace std;

const int Nmax = 1e5 + 5,INF = 2e5 + 5;
int a[Nmax],dp[Nmax];
int N,K;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N >> K;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    memset(dp,INF,sizeof(dp));
    dp[1] = a[1];

    for(int i = 2; i <= N; ++i)
        for(int j = 1; j <= min(i - 1,K); ++j)
            if(i - j == 1)
                dp[i] = min(dp[i],abs(a[i - j] - a[i]));
            else
                dp[i] = min(dp[i],dp[i - j] + abs(a[i - j] - a[i]));
    cout << dp[N];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n%2==0) {
      cout << n << endl;
  } else {
      cout << n*2 << endl;
  }
}

Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e9;
const ll MOD=1e9+7;
// ac cmtr;
const ll MAX_N = 1e5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll arr[3005][3005];
deque <char> ans;

void lcs(string a,string b,ll n,ll m){
    f(i,1,n+1){
        f(j,1,m+1){
            //if(i==0 && j==0) arr[]
            if(a[i-1]==b[j-1]) arr[i][j]=arr[i-1][j-1]+1;
            else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        }
    }
    a='0'+a;
    b='0'+b;
    ll p=n,q=m;
    while(p>0 && q>0){
        if(a[p]==b[q]) {ans.push_front(a[p]);p--;q--;}
        else if(arr[p-1][q]>arr[p][q-1]){
            p--;
        }
        else {
            q--;
        }
        
    }

    
    
    
    //return arr[n][m];
}



int main(){
    fastio;
    string a,b;
    cin>>a>>b;
    lcs(a,b,a.size(),b.size());
    //ll ans1=lcs(a,b,a.size(),b.size());
    //cout<<ans1<<endl;
    f(i,0,ans.size()){
        cout<<ans[i];
    }
    return 0;
}   



Measured memory_bytes: 70656
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 25;
const double pi = acos(-1);

vector<int> gr[N];
int n, dp[N][2];

void dfs(int v, int pr = -1) {
	bool fl = 0;
	dp[v][1] = dp[v][0] = 1;
	for(auto to: gr[v]) {
		if(to != pr) {
			fl = 1;
			dfs(to, v);
			dp[v][0] *= dp[to][0] + dp[to][1];
			dp[v][1] *= dp[to][0];
			dp[v][0] %= mod;
			dp[v][1] %= mod;
		}
	} 	
}

void solve() {
	//soln
	cin >> n;
	for(int i = 1; i < n; i++) {
		int l, r;
		cin >> l >> r;
		gr[l].pb(r);
		gr[r].pb(l);
	}
	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % mod << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


Measured memory_bytes: 26880
S=input()
if len(S)==1:
    print('No')
else:
    number=0
    for a in range(len(S) - 1):
        if S[a]=='h' and S[a+1]=='i':
            number+=1
    if number==len(S)/2:
        print('Yes')
    else:
        print('No')
        

Measured memory_bytes: 2940
use proconio::input;

fn main() {
    input! {
        k: u64,
    }

    let mut ans = 0;
    for i in 1..=k {
        for j in 1..=k {
            for l in 1..=k {
                ans += gcd3(i, j, l);
            }
        }
    }

    println!("{}", ans);
}

fn gcd3(a: u64, b: u64, c: u64) -> u64 {
    gcd(a, gcd(b, c))
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while b != 0 {
        let tmp = a - (a / b) * b;
        a = b;
        b = tmp;
    }
    a
}

Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <array>

typedef long long int llint;


int tree_size(const std::vector<std::vector<int> >& s, int head){
  std::queue<std::array<int, 3> > que; //node-id, depth, prev
  //std::cout << "start" << " " << head << std::endl;
  que.push({head, 1, -1});

  std::vector<int> group(s.size(), -1);
  group[head] = 1;
  int final = 0;
  while(!que.empty()){
    std::array<int, 3> now = que.front();
    //std::cout << now[0] << " dep" << now[1] << std::endl;
    que.pop();

    for(int i=0; i<s[now[0]].size(); i++){
      if(!s[now[0]][i]) continue; //there is no edge
      if(group[i] != -1){
	//std::cout << now[0] << "  " << i << std::endl;
	if(group[i] != now[1]-1 && group[i] != now[1]+1) return -1;
      }else{
	que.push({i, now[1]+1, now[0]});
	group[i] = now[1]+1;
      }
    }
    final = now[1];
  }
  return final;
}
int max_length(const std::vector<std::vector<int> >& s){
  int max_depth = -1;
  for(int i=0; i<s.size(); i++){
    int temp = tree_size(s, i);
    if(max_depth < temp) max_depth = temp;
  }
  return max_depth;
}

int main(void){
  int n;
  std::cin >> n;
  std::vector<std::vector<int> > s(n, std::vector<int>(n));
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      char c;
      std::cin >> c;
      s[i][j] = c-'0';
    }
  }
  std::cout << max_length(s) << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

vector<vector<int>> G(100005);
int parent[20][100005];
int depth[100005];
int root=0;
 
void dfs(int v,int p, int d){
    parent[0][v]=p;
    depth[v]=d;
    for (auto w:G[v]){
        if(w!=p)dfs(w,v,d+1);
    }
}
 
void init(int V){
    dfs(root,-1,0);
    for(int k=0;k+1<20;k++){
        for (int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}
 
int lca(int u, int v){
    if(depth[u]>depth[v])swap(u,v);
    for(int k=0;k<20;k++){
        if((depth[v]-depth[u])>>k & 1){
            v=parent[k][v];
        }
    }
    if (u==v)return u;
    for (int k=20-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<ll> dist(55);
void dfs2(int s, int p, ll d) {
    dist[s] = d;
    for(auto x:G[s]) {
        if(x==p) continue;
        ll d2 = (d|(1LL<<x));
        dfs2(x,s,d2);
    }
}


int main(){
    int N; cin >> N;
    REP(i,N-1) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int M; cin >> M;
    vector<pair<int,int>> P;
    REP(i,M) {
        int u, v; cin >> u >> v; u--, v--;
        if (u>v) swap(u,v);
        P.push_back(make_pair(u,v));
    }
    init(N);
    dfs2(0,-1,0);
    vector<int> P2(N); /* P2[i]: iとその親を結ぶ辺についてそれらが満たす制約を2進数でM桁の数字としてもつ。ただしiが根となるときは0とする。 */
    FOR(i,1,N) {
        REP(j,M) {
            int u = P[j].first, v = P[j].second;
            ll d = ((dist[u]|dist[v])&(~dist[lca(u,v)]));
            if((d>>i)&1) P2[i] |= (1<<j);
        }
    }
    vector<vector<ll>> dp(1<<M,vector<ll>(N));
    dp[0][0] = 1;
    REP(i,1<<M)REP(j,N-1) {
        dp[i][j+1] += dp[i][j];
        dp[i][j+1] += dp[i&(~P2[j+1])][j];  
    }
    cout << dp[(1<<M)-1][N-1] << endl;
    return 0;
}

Measured memory_bytes: 459264
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
int a,b;
int main() 
{
	cin>>a>>b;
	if(a+b==15){
		cout<<"+";
		return 0;
	} 
	if(a*b==15){
		cout<<"*";
		return 0;
	}
	cout<<"x";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
typedef pair <lli,lli> pll;
 
 
lli countGreater(lli arr[], lli n, lli k) 
{ 
    lli l = 0; 
    lli r = n - 1; 
  
    // Stores the index of the left most element 
    // from the array which is greater than k 
    lli leftGreater = n; 
  
    // Finds number of elements greater than k 
    while (l <= r) { 
        lli m = l + (r - l) / 2; 
  
        // If mid element is greater than 
        // k update leftGreater and r 
        if (arr[m] > k) { 
            leftGreater = m; 
            r = m - 1; 
        } 
  
        // If mid element is less than 
        // or equal to k update l 
        else
            l = m + 1; 
    } 
  
    // Return the count of elements greater than k 
    return (n - leftGreater); 
}

bool is_palin(string input)
{
if (input == string(input.rbegin(), input.rend())) 
    return true;
return false;
}
void solve()
{
    double a;
    cin>>a;
    cout<<deci(10)<<(double)((a/3)*(a/3)*(a/3));

}
 
int main()
{
    kira; 
 
    lli t=1; //cin>>t;
    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int n, k, s;
int calc(int x, int cnt, int sum) {
  if(cnt == k) {
    return sum == s;
  }
  if(sum > s) return 0;
  int ret = 0;
  FOR(i,x+1,n+1) {
    ret += calc(i, cnt + 1, sum + i);
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>n>>k>>s,n||k||s) {
    cout << calc(0, 0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A),b(B);
    int x,y,c,mini,amini=100010,bmini=100010;
    rep(i,A){
        cin>>a[i];
        amini=min(amini,a[i]);
    }
    rep(i,B){
        cin>>b[i];
        bmini=min(bmini,b[i]);
    }
    mini=amini+bmini;
    rep(i,M){
        cin>>x>>y>>c;
        mini=min(mini,a[x-1]+b[y-1]-c);
    }
    cout<<mini;
}

Measured memory_bytes: 4028
f=lambda:map(int,input().split())
n=int(input())
lh,lz=[],[]
for _ in range(n):
  x,y,h=f()
  if h: lh+=[(x,y,h)]
  else: lz+=[(x,y)]
for X in range(101):
  for Y in range(101):
    x,y,h=lh[0]
    H=h+abs(x-X)+abs(y-Y)
    for x,y,h in lh:
      if H!=h+abs(x-X)+abs(y-Y): break
    else:
      if all(H-abs(x-X)-abs(y-Y)<1 for x,y in lz):
        print(X,Y,H)

Measured memory_bytes: 9200
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#define MAX 100000
#define NIL -1
using namespace std;

int n,id;
vector<int> v[MAX];
int color[MAX], frd[MAX + 5] = {};

void dfs(int r,int c) {
    stack<int> s;
    s.push(r);
    color[r] = c;
    frd[c]++;
    
    while (!s.empty()) {
        int u = s.top(); s.pop();
        for (int i = 0; i < v[u].size(); i++) {
            int k = v[u][i];
            if (color[k] == NIL) {
                color[k] = c;
                frd[c]++;
                s.push(k);
            }
        }
    }
}

void assignColor() {
    id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0;u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int m, k;
    cin >> n >> m >> k;
    int a, b,c,d;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    assignColor();
    for (int i = 0; i < k;i++) {
        cin >> c >> d;
        if (color[c - 1] == color[d - 1]) {
            v[c - 1].push_back(d - 1);
            v[d - 1].push_back(c - 1);
        }
    }   
    for (int i = 0; i < n;i++) {
        int cnt = frd[color[i]] - v[i].size()-1;
        cout << cnt << " ";
    }
    cout << endl;
}


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


int digs(int n){
	int sum = 0;
	int dig;
	while(n){
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}


int main(){
	int n, a, b;
	int sum = 0;
	cin >> n >> a >> b;

	for(int i = 1;i <= n;i++){
		int dig = digs(i);
		if(a <= dig && dig <= b) sum += i;
	}

	cout << sum << endl;

	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    char a;
    cin >> a;
    if(a>='A' && a<='Z')
        cout << "A\n";
    else
    {
        cout << "a\n";
    }
    
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){


  int a,b,c,i;


  int count;


  scanf("%d %d %d\n",&a,&b,&c);


  for(i=a,count=0;i<=b;i++){


    if(c%i==0)count ++;


  }


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


return 0;


}

Measured memory_bytes: 600
s = input()
if 'BC' not in s:
  print(0)
  import sys
  sys.exit()
t = s.split('BC')
m = 0
ans = 0
for l in t[:-1]:
  cnt = 0
  for i in range(len(l)-1,-1,-1):
    if l[i]!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m
print(ans)


Measured memory_bytes: 46704
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    map<string, string> m;
    m.emplace("Sunny", "Cloudy");
    m.emplace("Cloudy", "Rainy");
    m.emplace("Rainy", "Sunny");
    string s;
    cin >> s;
    cout << m[s];
    return 0;

    return 0;
}

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

#define lli long long int

int main()
{
 string s;
 cin>>s;
lli n=1,c=0;

for (int i=1;i<s.length();i++)
{
    c=0;
    for(int j=0;j<i;j++)
    {
        if (s[i]==s[j])
            break;
        else
            c++;
    }
    if(i==c)
        n++;
}

if(n==2)
    cout<<"Yes";
else
    cout<<"No";

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
int main() {
    Int n;
    cin >> n;
    Int suma = 0, sumb = 0;
    vector<Int> va, vb, diffs;
    rep(i, n) {
        Int a;
        cin >> a;
        va.PB(a);
        suma += a;
    }
    rep(i, n) {
        Int b;
        cin >> b;
        vb.PB(b);
        sumb += b;
        diffs.PB(b - va[i]);
    }
    if (suma > sumb) {
        puts("No");
        return 0;
    } else if (suma == sumb) {
        rep(i, n) {
            if (diffs[i] != 0) {
                puts("No");
                return 0;
            }
        }
        puts("Yes");
        return 0;
    } else {
        auto sumdiff = sumb - suma;
        rep(i, n) {
            auto d = diffs[i];
            if (d > 0) {
                sumdiff -= (d + 1) / 2;
                if (sumdiff < 0) {
                    puts("No");
                    return 0;
                }
            }
        }
        puts("Yes");
        return 0;
    }
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int compress( vector< int >& x,const int w){
  vector< int > xs;
  for(int i = 0; i < x.size() ; i++ ){
    for(int d = -1; d <= 1 ; d++ ){
      int nx = x[i] + d;
      if(0 <= nx && nx < w) xs.push_back(nx);
    }
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  for(int i = 0 ; i < x.size() ; i++ ){
    x[i] = lower_bound(xs.begin(),xs.end(),x[i]) - xs.begin();
  }
  return xs.size();
}
int main(){
  int w, h, n;
  const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
  vector< int > x, y;
  while(cin >> w >> h, w){
    cin >> n;
    x.resize(2 * n), y.resize(2 * n);
    for(int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> x[n + i] >> y[n + i];
    }
    int neww, newh;
    neww = compress( x, w);
    newh = compress( y, h);
    bool mas[2000][2000] = {{}};
    for(int i = 0; i < n; i++){
      for(int j = x[i]; j < x[n + i]; j++){
        for(int k = y[i]; k < y[n + i]; k++){
          mas[k][j] = true;
        }
      }
    }
    int ret = 0;
    queue< int > quex, quey;
    for(int i = 0; i < newh ; i++ ){
      for(int j = 0; j < neww; j++ ){
        if(!mas[i][j]++){
          ret++;
          quex.push(j), quey.push(i); //あえてBFS
          while(!quex.empty()){
            int x = quex.front(), y = quey.front();
            quex.pop(), quey.pop();
            for(int i = 0 ; i < 4 ; i++ ){
              int ny = y + dy[i], nx = x + dx[i];
              if(ny < 0 || nx < 0 || nx >= neww || ny >= newh) continue;
              if(!mas[ny][nx]){
                quex.push(nx), quey.push(ny);
                mas[ny][nx] = true;
              }
            }
          }
        }
      }
    }
    cout << ret << endl;
  }
}

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

struct pt {
    LL x, y;
    pt(): x(0), y(0) {}
    pt(LL x, LL y): x(x), y(y) {}
};
pt operator-(pt A, pt B) { return {A.x-B.x, A.y-B.y}; }

bool above(pt A, pt B, pt C) {
    B = B-A, C = C-A;
    return B.x * C.y - B.y * C.x >= 0;
}


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

    int it = 0;
    for (int i = 0; i < N; i++) if (A[i] > A[it]) it = i;
    rotate(A.begin(), A.begin() + it, A.end());
    rotate(B.begin(), B.begin() + it, B.end());
    A.push_back(A[0]);
    B.push_back(B[0]);
    vector<LL> C(N+1, 0);
    for (int i = 2; i <= N; i++) C[i] = 2*(C[i-1]+B[i-1]) - C[i-2];
    
    vector<pt> hull = {{0, A[0]-C[0]}};
    for (int i = 1; i <= N; i++) {
        pt P = {i, A[i]-C[i]};
        while (hull.size() >= 2 and above(hull[hull.size()-2], hull.back(), P)) hull.pop_back();
        hull.push_back(P);
    }
    
    LL twice_res = 0;
    for (int i = 1; i < (int)hull.size(); i++) {
        LL dx = hull[i].x - hull[i-1].x;
        LL area = hull[i-1].y * (dx+1) + hull[i].y * (dx-1);
        twice_res += area;
    }
    for (int i = 0; i < N; i++) twice_res += 2*C[i];

    double res = twice_res;
    res /= 2*N;
    cout.precision(12);
    cout << fixed << res << endl;
}


Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> ans(n+1);
  for(int i = 0; i < n-1; i++){
      cin >> a.at(i);
      ans[a[i]]++;
  }
  for(int i = 1; i < n+1; i++){
      cout << ans[i]<< endl;
  }
}


Measured memory_bytes: 6440