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

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

    for (int i = 1; i < 10; i++) {
        if (N%i != 0)
            continue;

        int j = N / i;
        if (j > 0 && j < 10) {
            cout << "Yes" << endl;

            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   int n;cin >> n;
   vector<ll>a(n);
   for(int i = 0;i<n;i++) cin >> a[i];
   vector<ll>suf(n,0);
   suf[n-2] = a[n-1];
   for(int i = n-3;i>=0;i--){
    suf[i] = suf[i+1] + a[i+1];
   }
   ll ans = 0;
   for(int i = 0;i<n;i++){
    ans += ((a[i])*(suf[i]%mod))%mod;
    ans = (ans+mod)%mod;
   }
   cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 6364
import math


class Triangle(object):
    def __init__(self, a, b, C):
        self.a = a
        self.b = b
        self.C = C * math.pi / 180

    def getHeight(self):
        return self.b * math.sin(self.C)

    def getArea(self):
        return (self.a * self.getHeight()) / 2
    
    def getPerimeter(self):
        return self.a + self.b + math.sqrt(self.a ** 2 + self.b ** 2 - 2 * self.a * self.b * math.cos(self.C))


a = [int(e) for e in input().split()]
tri = Triangle(a[0], a[1], a[2])
print(tri.getArea())
print(tri.getPerimeter())
print(tri.getHeight())



Measured memory_bytes: 5720
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
  int h, w;
  while(1){
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    for(int tmprow = 0; tmprow < h; tmprow++){
      for(int tmpcol = 0; tmpcol < w; tmpcol++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main()
{
    long long int n,k=0;
    cin >> n;
    long long int a[n],ans[n];
    for(int i=0;i<n;++i)
    {
         cin >> a[i];
    }
    for(int i=0;i<n;++i)
    {
        ans[i]=0;
    }
    for(int i=0;i<n;++i)
    {
        if(a[i]>a[i+1] || a[i]==a[i+1])
        {
             ans[k]++;
        }
        else
        {
             k++;
        }
    }
    int max=ans[0];
    for(int i=1;i<n;i++)
    {
        if(max<ans[i])
        {
            max=ans[i];
        }
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc100/tasks/abc100_c
# C - *3 or /2

n = int(input().split()[0])
a_list = list(map(int, input().split()))

# 2で割れる数は何回か
def f(value):
    x = value
    count = 0
    while x % 2 == 0:
        x = x / 2
        count += 1
    return count

ans = sum([f(a) for a in a_list])
print(int(ans))


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll h,w;
set<pair<int,int>> black;
vin dx={-1,0,1,-1,0,1,-1,0,1};
vin dy={-1,-1,-1,0,0,0,1,1,1};
int nx,ny,sum;

int black_count(int x,int y){
    sum=0;
    rep(i,9){
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx<=0||w<nx||ny<=0||h<ny)return 10;
        if(black.count(mp(ny,nx)))sum++;
    }
    return sum;
}

int main(){
    int n;cin>>h>>w>>n;
    vin a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
        black.insert(mp(a[i],b[i]));
    }
    vll num(11);num[0]=(h-2)*(w-2);
    rep(i,n)rep(j,9)num[black_count(b[i]+dx[j],a[i]+dy[j])]++;
    rep2(i,1,10){
        num[i]/=i;
        num[0]-=num[i];
    }
    rep(i,10)cout<<num[i]<<endl;
}

Measured memory_bytes: 8812
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var str = cin.ReadLine;
            var strList = str.ToCharArray();
            var ReversedstrList = strList.Reverse().ToArray();
            var count = 0;
            //var ans = 0;
            var indexOfA =0;
            var indexOfZ = 0;
            
            for(int i =0; i<strList.Length; i++){
                
                if(strList[i]=='A'){
                    indexOfA = i;
                    break;
                }
            }
            
            for(int j =0; j<strList.Length; j++){
                //WriteLine(strList[j]);
                
                if(ReversedstrList[j]=='Z'){
                    indexOfZ = j;
                    break;
                }
            }
            
            var ans = (strList.Length-(indexOfZ+indexOfA));
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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


int sss(string a)
{
	int x;
	stringstream ss;
	ss<<a;
	ss>>x;
	return x;
}

string iii(int x)
{
	string s;
	stringstream ss;
	ss<<x;
	ss>>s;
	return s;
}


int main()
{
	int k,a;
	string s,b;
	stringstream ss;
	vector<string>v;
	vector<pair<int,string>>w;
	set<string>S;
	bool flag=true;

	cin>>k;

	for(int i=1;i<=9;i++)
	{
		ss<<i;
		ss>>s;
		ss.clear();
		v.push_back(s);
	}

	
	for(int i=0;i<40000;i++)
	{
		if(v[i][v[i].size()-1]=='0')
		{
			v.push_back(v[i]+"0");
			v.push_back(v[i]+"1");
		}
		else if(v[i][v[i].size()-1]=='9')
		{
			v.push_back(v[i]+"8");
			v.push_back(v[i]+"9");
		}
		else
		{
			a=sss(v[i].substr(v[i].size()-1,1));
			v.push_back(v[i]+iii(a));
			v.push_back(v[i]+iii(a+1));
			v.push_back(v[i]+iii(a-1));
		}
	}
	for(int i=0;i<v.size();i++)
	{
		w.push_back(make_pair(v[i].size(),v[i]));
	}
	sort(w.begin(),w.end());
	cout<<w[k-1].second<<endl;
	return 0;
}

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

class Program
{
    static List<Node> nodes = new List<Node>();

    class Node
    {
        public int parentId = -1;
        public int depth = 0;
        public List<int> childrenIds;
    }

    static void Main(string[] args)
    {
        // 行数を取得
        int n = int.Parse(Console.ReadLine().Split()[0]);
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0]].childrenIds = nums.GetRange(2, nums[1]);
            for (int j = 2; j < nums[1] + 2; j++)
            {
                nodes[nums[j]].parentId = nums[0];
            }
        }

        Node root = nodes.First(node => node.parentId == -1);

        dfs(root, 0);

        // 出力
        for (int i = 0; i < n; i++)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("node ");
            sb.Append(i.ToString());
            sb.Append(": parent = ");
            sb.Append(nodes[i].parentId.ToString());
            sb.Append(", depth = ");
            sb.Append(nodes[i].depth.ToString());
            if (nodes[i].parentId == -1)
            {
                sb.Append(", root, [");
            }
            else if (nodes[i].childrenIds.Count() == 0)
            {
                sb.Append(", leaf, [");
            }
            else
            {
                sb.Append(", internal node, [");
            }
            for (int j = 0; j < nodes[i].childrenIds.Count(); j++)
            {
                sb.Append(nodes[i].childrenIds[j].ToString());
                if (j < nodes[i].childrenIds.Count() - 1)
                {
                    sb.Append(", ");
                }
            }
            sb.Append("]");

            System.Console.WriteLine(sb.ToString());
        }
    }

    static void dfs(Node node, int depth)
    {
        node.depth = depth;
        foreach (var childId in node.childrenIds)
        {
            dfs(nodes[childId], depth + 1);
        }
    }
}


Measured memory_bytes: 29944
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)  throws Exception{

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] str = reader.readLine().split(" ");
		int A = Integer.parseInt(str[0]);
		int B = Integer.parseInt(str[1]);
		int C = Integer.parseInt(str[2]);

		int ans = 0;
		if (A * C <= B) {
			ans = C;
		}
		else {
			ans = B / A;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define rep(i,n)        for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int Mod = 1000000007;
ll dp[2][2][110];
string s;
int d;
signed main(){
	ios::sync_with_stdio(false);
	cin >> s >> d;
	for(int i = 0; i < (s[0] - '0'); i++) dp[0][0][i % d]++;
	dp[1][0][(s[0] - '0') % d]++;
	for(int i = 1; i < s.size(); i++){
		int now = i & 1, prev = (i - 1) & 1;
		rep(j, d) dp[0][now][j] = dp[1][now][j] = 0;
		rep(j, d){
			dp[1][now][(j + (s[i] - '0')) % d] += dp[1][prev][j];
			dp[1][now][(j + (s[i] - '0')) % d] %= Mod;
			for(int k = 0; k < 10; k++){
				dp[0][now][(j + k) % d] += dp[0][prev][j];
				dp[0][now][(j + k) % d] %= Mod;
				if(k < (s[i] - '0')){
					dp[0][now][(j + k) % d] += dp[1][prev][j]; 
					dp[0][now][(j + k) % d] %= Mod;
				}
			}
		}
	}
	int a = (s.size() - 1) & 1;
	cout << ((dp[0][a][0] + dp[1][a][0] - 1) % Mod + Mod) % Mod << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,k;
    cin>>n>>m>>k;
    rep(i,n+1){
        rep(j,m+1){
            ll black=i*m+j*n-i*j*2;
            if(black==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            if bp[j]==0:
                bp[j] = i

def fact(n):
    ret=1
    while n>1:
        now=n
        cnt=0
        p=bp[now]
        while now % p == 0:
            now//=p
            cnt+=1
        ret*=cnt+1
        n=now
    return ret

ans=0
for i in range(1,n+1):
    ans += i*fact(i)

print(ans)

Measured memory_bytes: 152280
import sys
readline = sys.stdin.readline

N = int(readline())

def count_div(x):
  div = set()
  for i in range(1, int(x ** 0.5) + 1):
    if x % i == 0:
      div.add(i)
      div.add(x // i)
  return len(div)

ans = 0
for i in range(1, N + 1, 2):
  if count_div(i) == 8:
    ans += 1
print(ans)
  

Measured memory_bytes: 9440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;
        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadIntArray();

            long ret = dfs(0, N);
            Console.WriteLine(ret);

        }

        long dfs(int L, int R)
        {
            int n = R - L;
            if (n <= 1) return 0;
            // [L, M)
            // [M, R)
            int M = (L + R) / 2;

            long ret = 0;
            ret += dfs(L, M);
            ret += dfs(M, R);

            int r = M;
            for (int l = L; l < M; l++)
            {
                while (r < R && A[l] >= A[r])
                {
                    r++;
                }
                ret += (r - M);
            }

            Array.Sort(A, L, R - L);

            //  Console.WriteLine($"{L}, {R}, {ret}, -- {string.Join(", ", A)}");
            return ret;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 26368
function main()
	N=parse(Int,readline())
	c=map(x->parse(Int,x),split(readline()))
	G=[Int[] for _=1:N]
	for _=2:N
		u,v=map(x->parse(Int,x),split(readline()))
		push!(G[u],v)
		push!(G[v],u)
	end
	cnt=zeros(Int,N)
	ans=zeros(Int,N)
	function dfs(u,p)
		ret=1
		pre=sto=cnt[c[u]]
		for v=G[u]
			if v!=p
				t=dfs(v,u)
				ret+=t
				k=t-(cnt[c[u]]-sto)
				sto=cnt[c[u]]
				ans[c[u]]-=div(k*(k+1),2)
			end
		end
		cnt[c[u]]=pre+ret
		ret
	end
	dfs(1,0)
	for i=1:N
		ans[i]+=div(N*(N+1),2)
		k=N-cnt[i]
		ans[i]-=div(k*(k+1),2)
		println(ans[i])
	end
end
main()


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

using namespace std;

int lcs(string X,string Y){
  //staticにしないと実行時にスタックオーバーフローになる
  static int c[1001][1001];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  int q;cin>>q;
  while(q--){
    string a,b;cin>>a>>b;
    cout << lcs(a,b) << endl;
  }
  return 0;
}



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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) {
        rep(n) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        return ((par[x] == x) ? x : par[x] = find(par[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

struct Edge{
    int from, to; ll cost;
    Edge(int from, int to, ll cost){
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
    bool operator<(const Edge &e) const{
        return cost < e.cost;
    }
};

class Graph{
    public:
    int V,E;
    vector<Edge> edges;
    Graph(int n, vector< pair<ll, int> > x, vector< pair<ll, int> > y){
        V = 2*n;
        E = 2*n-2;
        rep(n-1){
            edges.push_back(Edge(x[i+1].second, x[i].second, x[i+1].first - x[i].first));
            edges.push_back(Edge(y[i+1].second, y[i].second, y[i+1].first - y[i].first));
        }
    }

    ll kruskal(){
        ll ret = 0LL;
        UnionFind uf = UnionFind(V);
        sort(all(edges));
        for(Edge e: edges){
            if(!uf.is_same(e.from, e.to)){
                ret += e.cost;
                uf.unite(e.from, e.to);
            }
        }
        return ret;
    }
};

int main(){
    int n;
    cin >> n;
    vector< pair<ll, int> > x(n), y(n);
    rep(n){
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }

    sort(all(x)); sort(all(y));

    Graph g = Graph(n, x, y);
    cout << g.kruskal() << endl;
}


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

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

	vector<int> dp(W+1, -1);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		int v, w;
		cin >> v >> w;
		auto pre = dp;
		for (int j = 0; j <= W - w; j++) {
			if (pre[j] >= 0) dp[j + w] = max(dp[j + w], pre[j] + v);
		}
	}

	int ans = 0;
	for (int i = 0; i <= W; i++) {
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3240
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p;
  int s[1000];
  int sum;
  while(1){
    sum=0;
    cin>>p;
    if(p==0) break;
    for(int i=0;i<p;i++){
      cin>>s[i];
      sum+=s[i];
    }
    sort(s,s+p);
    for(int j=0;j<p;j++){
      /* cout<<s[j]<<endl;*/
    }
    cout<<(sum-s[0]-s[p-1])/(p-2)<<endl;
  }
  return 0;
}
    


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> p(k);
    rep(i, k) cin >> p[i];
    
    rep3(i, n, inf) {
        int tmp = i;
        set<int> s;
        while (tmp) {
            s.insert(tmp % 10);
            tmp /= 10;
        }
        int flg = 0;
        rep(j, k) {
            if (s.find(p[j]) != s.end()) {
                flg = 1;
                break;
            }
        }
        if (flg == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,a,b = li()
print(min(a,b), max(0, a+b-n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf (long long)1e18
using namespace std;

struct data {
  long long a, b, c;
};

long long n, m, p;
long long dist[2600] = {0};
vector<data> edge;

long long solve();
bool bell();

int main() {
  cin >> n >> m >> p;
  for(int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edge.push_back({--a, --b, p - c});
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i < n; ++i) dist[i] = inf;
  dist[0] = 0;
  for(int i = 0; i < n - 1; ++i) bell();
  for(int i = 0; i < n; ++i)
    if(bell()) return -1;
  return max(-dist[n - 1], 0LL);
}

bool bell() {
  bool ch = 0;
  for(int i = 0; i < m; ++i) {
    data now = edge[i];
    if(dist[now.a] != inf &&
       dist[now.b] > dist[now.a] + now.c) {
      if(now.b == n - 1) ch = 1;
      dist[now.b] = dist[now.a] + now.c;
    }
  }
  return ch;
}

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

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

using namespace std;
typedef long long ll;

char a[5] = {'a', 'i', 'u', 'e', 'o'};
void solve() {
	char c;
	cin >> c;
	bool ans = false;
	rep(i, 0, 5) {
		if (c == a[i]) ans = true;
	}
	if (ans) {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}
}

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

Measured memory_bytes: 764
#include<stdio.h>
 
int main()
{
  int a,b,c;
  scanf("%d %d %d\n",&a,&b,&c);
  if(a <= b && b <= c)
    printf("%d %d %d\n",a ,b ,c);
  else if(a <= c && c <= b)
    printf("%d %d %d\n",a ,c ,b);
  else if(b <= a && a <= c)
    printf("%d %d %d\n",b ,a ,c);
  else if(b <= c && c <= a)
    printf("%d %d %d\n",b ,c ,a);
  else if(c <= a && a <= b)
    printf("%d %d %d\n",c ,a ,b);
  else if(c <= b && b <= a)
    printf("%d %d %d\n",c ,b ,a);
return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  vll l;
  l.push_back(2);
  l.push_back(1);
  REP(i,n-1) {
    l.push_back(l[i]+l[i+1]);
  }
  cout << l[n] << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  ll b=0;
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(b-vec.at(a-1)>vec.at(a-1)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
  return 0;
}


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

void	ft_swap(long *a, long *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void	ft_sort(long *d, long n)
{
	int i = 0;
	int j;
	while (i < n - 1)
	{
		j = i + 1;
		while (j < n)
		{
			if (d[i] > d[j])
				ft_swap(&d[i], &d[j]);
			j++;
		}
		i++;
	}
}

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void)
{
	long N;
	scanf("%ld", &N);
	long d[N];
	long count = 0;
	long arc = N / 2;
	long abc = (N / 2) - 1;
	long i = 0;
	while (i < N)
	{
		scanf("%ld", &d[i]);
		i++;
	}
	qsort(d, sizeof(d) / sizeof(d[0]), sizeof(long), cmpnum);
	i = 0;
	printf("%ld\n",d[arc] - d[abc]);
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool judge;
  
  for(int i = 0; i < 105; i++){
    c = c - b;
    if(c <= 0){
      judge = true;
      break;
    }
    a = a - d;
    if(a <= 0){
      judge = false;
      break;
    }
  }
  
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long n;
	cin >> n;
	long long mod=(n*(n+1))/2;
	mod-=n;
	cout << mod << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define all(v) v.begin(),v.end()
int mod =1e18+2;
        
int32_t main()
{
    int a;
    double b;
    cin>>a>>b;
    int d = round(b*100);
    int ans = a*d;
    ans/=100;
    cout<<ans;
    //cout<<floor(y);
}

Measured memory_bytes: 3780
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int[] h = new int[n];
		double temp = 100000000;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			if (Math.abs(a - (t - h[i] * 0.006)) < temp) {
				temp = Math.abs(a - (t - h[i] * 0.006));
				ans = i+1;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

int n, m;
vector<int> x;
vector<int> gap;

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

    REP(i, m) {
        int xi;
        cin >> xi;
        x.push_back(xi);
    }
    
    if (n>=m) {
        cout << "0" << endl;
        return 0;
    }

    sort(x.begin(), x.end());

    REP(i, m-1) {
        gap.push_back(x[i+1] - x[i]);
    }

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

    int output = x[x.size()-1] - x[0];
    REP(i, n-1) {
        output -= gap[i];
    }
    cout << output << endl;
}


Measured memory_bytes: 1400
def lcm(x, y):
  return (x*y)//gcd(x,y)

def gcd(v, w):
  while w:
    v, w = w, v % w
  return v

def calc(l, m, n):
  return l//m + l//n - l//lcm(m,n)

a, b, c, d = map(int,input().split())

tmp = b-a+1
aa = calc((a-1), c, d)
bb = calc(b, c, d)
print(tmp - (bb - aa))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int, M: int, A: "List[int]"):
    answer = N - sum(A)
    if answer < 0:
        answer = -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    answer = solve(N, M, A)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9976
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		Integer n = new Integer(Integer.parseInt(sc.next())); // 品物の種類数
		Integer k = new Integer(Integer.parseInt(sc.next())); // 何個買うか
		Integer x[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			x[i] = new Integer(Integer.parseInt(sc.next()));
		}

		// ソート
		Arrays.sort(x);

		// 安いものk個を買おう
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += x[i];
		}
		System.out.println(sum);

	}
}

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

typedef long long ll;

#define F first
#define S second

int ans = 0;
int n, m, q;
vector<int> v;
vector<array<int, 4>> Q;

void backtrack(int i) {
    if (i == n) {
        // for (int i = 0; i < n; i++)
        //     cout << v[i] << " ";
        // cout << '\n';
        int sc = 0;
        for (array<int, 4> arr : Q) {
            int a = arr[0], b = arr[1], c = arr[2], d = arr[3];
            if (v[b - 1] - v[a - 1] == c)
                sc += d;
        }
        ans = max(ans, sc);
    } else {
        for (int x = (i ? v[i - 1] : 1); x <= m; x++) {
            v.push_back(x);
            backtrack(i + 1);
            v.pop_back();
        }
    }
}

void solve() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        Q.push_back({a, b, c, d});
    }
    backtrack(0);
    cout << ans << '\n';
}

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

    solve();
    return 0;
}


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

int main(int argc, char** argv){
  int a, b;
  cin >> a >> b;
  if(a<=0&&b>=0){
    cout << "Zero";
  }else if(a>0){
    cout << "Positive";
  }else{
    if((b-a)%2) cout << "Positive";
    else cout << "Negative";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 1000000007
#define N 1000006
#define INF 1000000000000000000
using namespace std;

void solve(){
    string s;
    cin>>s;
    int n = s.length();
    int ans=0,curr=0,prev=0;
    char c = s[0];
    for(int i=0;i<n;i++){
        if(s[i]==c){
            curr++;
            if(i==n-1){
                if(c=='>'){
                    if(curr>prev) ans += (curr-prev);
                    ans += (curr*(curr-1))/2;
                }
                else{
                    ans += (curr*(curr+1))/2;
                }
            }
        }
        else{
            if(c=='>'){
                if(curr>prev) ans += (curr-prev);
                ans += (curr*(curr-1))/2;
            }
            else{
                ans += (curr*(curr+1))/2;
            }
            prev=curr;
            curr=1;
            c=s[i];
            if(i==n-1 && c=='<'){
                ans++;
            }
        }
        //cout<<ans<<" ";
    }
    cout<<ans<<"\n";
}

signed main(){
    //fastio
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1172
#include<iostream>
#include<algorithm>

using namespace std;
int main() {
    int n1, n2, n3, n4;
    cin >> n1 >> n2 >> n3 >> n4;

    int ns[4] = {n1, n2, n3, n4};
    sort(ns, ns+4);

    if (ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import re

s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()

m = re.match(u, s)
if m is None:
    m = re.match(u, t)
    if m is not None:
        b -= 1
else:
    a -= 1

print(a, b)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
# define M_PIl        3.141592653589793238462643383279502884
using namespace std;

typedef long long ll;
typedef long double ld;


int main(){
  string str;
  cin >> str;
  ll n;
  cin >> n;
  bool change = false;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    if(a==2){
      ll b;
      string c;
      cin >> b >> c;
      if(change){
        if(b==1){
          str.append(c);
        }
        else{
          str.insert(0,c);
        }
      }
      else{
        if(b==1){
          str.insert(0,c);
        }
        else{
          str.append(c);
        }
      }
    }
    if(a==1){
      change = !change;
    }
  }
  if(change){
    reverse(str.begin(),str.end());
  }
  cout << str << endl;
}

Measured memory_bytes: 1020
import sys
input = sys.stdin.readline
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
for t in range(X + Y + 1):
  if t == X + Y:
    print(0)
    exit(0)
  if X + Y - 2 * t == t:
    X -= t
    Y -= t
    break
if X < 0 or (Y < 0):
  print(0)
  exit(0)
class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(X + Y, mod)
#print(X, Y)
print(f.combi(X + Y, X))

Measured memory_bytes: 91876
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N, A;
ll dp[55][2600];

int main(){

    dp[0][0] = 1;
    cin >> N >> A;
    rep(i, N){
        ll x;
        cin >> x;
        rrep1(num, N)rrep1(sum, 2500){
            ll from_sum = sum - x;
            if(from_sum < 0)continue;
            dp[num][sum] += dp[num - 1][from_sum];
        }
    }
    ll ans = 0;
    rep1(num, N)rep1(sum, 2500)if(num * A == sum){
        ans += dp[num][sum];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<list>
#include<cmath>
using namespace std;
#define int long long
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a[400000];
int cnt = 1,ans=0;
signed main(){
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == cnt)cnt++;
		else ans++;
	}
	if (cnt == 1)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// #include "coins.h"
#include <iostream>
#include <numeric>
#include <vector>

#include <iterator>

using Probabilities = std::vector<double>;

/*There are two possible ways to get exactly j heads with i coins -

a) if (i-1) coins have j heads, and ith coin is tail, and

b) if (i-1) coins have j-1 heads, and ith coin is head

so

P(i, j) = P(i-1, j) * (1 - p[i]) + P(i-1, j-1) * p[i]*/
double probability_of_more_heads(const Probabilities& heads_probabilities)
{
    std::vector<double> prev(heads_probabilities.size() + 1, 0);
    // dp[i] - probability that we have i heads so far
    std::vector<double> dp(heads_probabilities.size() + 1, 0);

    prev.front() = 1;

    for (size_t pos = 1; pos <= heads_probabilities.size(); ++pos) {
        for (size_t num_heads = 0; num_heads <= pos; ++num_heads) {
            const double p_heads{heads_probabilities[pos - 1]};
            const double p_tails{1 - p_heads};
            if (num_heads == 0)
                dp[num_heads] = prev[num_heads] * p_tails;
            else
                dp[num_heads] = prev[num_heads] * p_tails + prev[num_heads - 1] * p_heads;
        }
        std::swap(prev, dp);
    }

    // for (const auto& row : dp) {
    //     std::copy(row.cbegin(),
    //               row.cend(),
    //               std::ostream_iterator<
    //                   std::iterator_traits<decltype(row.cbegin())>::value_type>(
    //                   std::cout, ", "));
    //     std::cout << '\n';
    // }
    double ans{0};
    for (size_t num_heads = 0; num_heads <= heads_probabilities.size(); ++num_heads) {
        size_t num_tails = heads_probabilities.size() - num_heads;
        if (num_heads > num_tails)
            ans += prev[num_heads];
    }
    // std::copy(prev.cbegin(), prev.cend(), std::ostream_iterator<std::iterator_traits<decltype(prev.cbegin())>::value_type>(std::cout, ", "));
    // std::cout << '\n';
    return ans;
    // return std::accumulate(
    //     std::next(prev.cbegin(), prev.size() / 2),
    //     prev.cend(),
    //     double{0.0});
}

int main(int argc, char* argv[])
{
    size_t num_coins;
    std::cin >> num_coins;
    Probabilities heads_probabilities(num_coins);
    for (size_t i = 0; i < num_coins; ++i) {
        double p_heads;
        std::cin >> p_heads;
        heads_probabilities[i] = p_heads;
    }
    printf("%.10lf\n", probability_of_more_heads(heads_probabilities));
    // std::cout << probability_of_more_heads(heads_probabilities) << std::endl;
    return 0;
}



Measured memory_bytes: 384
N,A,B=map(int, input().split())
turn=0
while A!=1 and B!=N or turn==0:
  if A!=B-1:
    A+=1
  else:
      A=A-1
  if A<1:
      A=1
  if B!=A+1:
    B=B-1
  else:
    B=B+1
  if B>N:
      B=N
  turn+=1
if A==1:
  print('Borys')
else:
  print('Alice')

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        Console.WriteLine("ABC" + cin.next());
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;
    cin >> n;
    vi a(n);
    bool ok = true;
    rep(i,n){
        cin >> a[i];
        ok &= a[i]%2==0;
    }
    cout << (ok? "second" : "first") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

ll n, i;
ll A, B, ans, mm = 1LL << 60;
bool any;


int main()
{
//    freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> A >> B;
        if (A != B) any = true;
        ans += A;
        if (A > B) mm = min(mm, B);
    }

    if (!any) ans = 0;
    else      ans -= mm;
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int dp[310][310][310];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
}


Measured memory_bytes: 256
mod = 998244353

N = int(input())
S = input()

C = {"R": 0, "G": 0, "B": 0}

ans = 1
for s in S:
    a, b, c = sorted(C.values())
    C[s] += 1
    ans *= (b - a, c - b, 1)[(c < C[s]) + (b < C[s])]
    ans %= mod

for i in range(1, N + 1):
    ans *= i
    ans %= mod

print(ans)

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

int digitSum(int n)
{
    int a,sum=0;
    while(n !=0 )
    {
        a = n%10;
        n = n/10;
        sum=sum+a;
    }

    return(sum);
}

int main()
{
    int t,a,b,ans=0;
    cin>>t>>a>>b;

    for(int i=1;i<=t;i++)
    {
        if(digitSum(i)>=a && digitSum(i)<=b && digitSum(i)) ans=ans+i;

    }


    cout<<ans<<endl;


    return 0;
}


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

int map[MAX][MAX];
int ans, w, h;
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

void dfs(int x, int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) return;
	if (map[y][x]==0) return;
	map[y][x] = 0;
	for (int i=0; i<8; i++)
		dfs(x+dx[i], y+dy[i]);
}

int main() {
	while (cin >> w >> h, w||h) {
		for (int i=0; i<h; i++)
		for (int j=0; j<w; j++)
			cin >> map[i][j];

		ans=0;
		for (int i=0; i<h; i++)
		for (int j=0; j<w; j++)
			if (map[i][j]) { ans++; dfs(j, i); }

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

Measured memory_bytes: 0
# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush


def main():
    _, M = map(int, input().split())
    A = [-i for i in map(int, input().split())]
    heapify(A)

    discount = lambda: heappush(A, -(-heappop(A) // 2))
    for _ in range(M):
        discount()

    print(-sum(A))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20252